fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
nivekuil 2020-10-25T06:36:39.418200Z

I tried for a while to make targeting work, but there might be something I'm missing here: from Page, I call (df/load! this (comp/get-ident this) PageItemsQueryComponent {:params {:start 0 :end 10}}. This queries for [:page/id :page/size {:page/items [:item/id]}] and merges in a Page at e.g. [:page/id 1]. You're right that what I really want it to do is load a :page/items and append it to [:page/id 1 :page/items], but I have no idea how to do that with load -- if I use an ident to load it always grabs the whole entity, and I can't target only one attribute of that somewhere else? But I think it may be for the better anyway since pre-merge gives me a bit more control. I think the difference with the approach in the book is that I have to ask Page which items it would like to load, I can't load the Item directly.

tony.kay 2020-10-26T16:24:23.442500Z

you’re right, an ident-based load does not ever thing you’re doing a to-many (since the result will be to-one). A post-mutation is a good choice. Pre-merge is not really, since that is only meant to affect the merge, not other parts of the tree.

nivekuil 2020-10-26T22:38:22.444200Z

I think I would need the pre-merge state to do my fancy merge logic, which would have been clobbered by the time the post-mutation is called?

tony.kay 2020-10-27T01:12:05.444400Z

ah, yes

nivekuil 2020-10-25T06:41:19.418400Z

honestly I think a component-just-for-its-query with a pre-merge is actually pretty elegant in its own right

jlmr 2020-10-25T13:03:53.422Z

HI, I’ve just started experimenting with Fulcro (so far I really like the local reasoning that it enables) and I’m stuck with this simple component:

(defsc IdeaInput
  [this {:input/keys [idea]}] 
  {:query [:input/id :input/idea]
   :ident :input/id
   :initial-state (fn [{:keys [id]}]
                    {:input/id id
                     :input/idea "A string"})}
  (dom/div
    (dom/label "Idea: ")
    (dom/input {:value idea
                :onChange #(m/set-string!! this :input/idea :event %)})))
I would expect that typing in the input would also change the database. I can see something similar happening in this example: http://book.fulcrologic.com/#_the_function_as_a_child_pattern. When I try the above code and type something I see transactions happening in the Fulcro inspector, however the database is not updating. I’m probably missing something simple, all help welcome!

jlmr 2020-10-26T07:18:29.436600Z

Those things are indeed in the db

tony.kay 2020-10-26T16:25:46.442700Z

Did you compose that input to the root?

tony.kay 2020-10-26T16:25:55.442900Z

initial state and query have to compose to root

nivekuil 2020-10-25T13:08:56.422100Z

In reply to @￱_￱slack￱_￱￱_￱￱_￱t03￱_￱r￱_￱z￱_￱g￱_￱p￱_￱f￱_￱r=2d￱_￱u56￱_￱r03￱_￱v￱_￱n￱_￱w:nivekuil.comHI, I’ve just started experimenting with Fulcro (so far I really like the local reasoning that it enables) and I’m stuck with this simple component:&lt;code&gt;(defsc IdeaInput&lt;br /&gt; [this {:input/keys [idea]}] &lt;br /&gt; {:query [:input/id :input/idea]&lt;br /&gt; :ident :input/id&lt;br /&gt; :initial-state (fn [{:keys [id]}]&lt;br /&gt; {:input/id id&lt;br /&gt; :input/idea "A string"})}&lt;br /&gt; (dom/div&lt;br /&gt; (dom/label "Idea: ")&lt;br /&gt; (dom/input {:value idea&lt;br /&gt; :onChange #(m/set-string!! this :input/idea :event %)})))&lt;/code&gt;I would expect that typing in the input would also change the database. I can see something similar happening in this example: <http://book.fulcrologic.com/#_the_function_as_a_child_pattern>. When I try the above code and type something I see transactions happening in the Fulcro inspector, however the database is not updating. I’m probably missing something simple, all help welcome!jlmr: does it behave differently with m/set-string!, one exclamation point?

jlmr 2020-10-25T13:11:34.423Z

I’ve tried that already and it didn’t change anything

nivekuil 2020-10-25T13:20:03.423200Z

In reply to @￱￱slack￱￱￱￱￱￱t03￱￱r￱￱z￱￱g￱￱p￱￱f￱￱r=2d￱￱u56￱￱r03￱￱v￱￱n￱_￱w:nivekuil.comI’ve tried that already and it didn’t change anythingif you can see transactions happening in the inspector, what's the value of the transaction? under the Transactions tab

nivekuil 2020-10-25T13:21:02.423400Z

In reply to @.:nivekuil.comif you can see transactions happening in the inspector, what's the value of the transaction? under the Transactions tabin that book example it becomes (com.fulcrologic.fulcro.mutations/set-props {:block/name "a"}) if I change "A Block" to "a" for example

jlmr 2020-10-25T16:03:56.423600Z

@kevin842 sorry, wasn’t at my desk. Transaction looks like this: (com.fulcrologic.fulcro.mutations/set-props {:input/idea "A stringa"})

jlmr 2020-10-25T16:04:14.423800Z

When I add an a to the string in the input

jlmr 2020-10-25T16:04:50.424Z

However in the transactions tab, the details for this transactions show:

Diff added
nil
Diff removed
nil

Jakub Holý 2020-10-25T16:22:01.424200Z

Maybe look at the code of the mutation, what it actually does? Add some logs to it?

jlmr 2020-10-25T17:20:30.424400Z

@holyjak the code for the mutation is provided by fulcro. Pretty sure it is the generated by mutations/set-string!!

eoliphant 2020-10-25T17:26:03.424600Z

could you share the code where the input is used? Common gotcha in Fulcro is missing wiring somewhere between the component in question and the root

jlmr 2020-10-25T17:47:37.425800Z

Sure, it’s my first experiment with Fulcro, so there isn’t much code yet. This is the Root component:

(defsc Root
  [_this {:keys [input ideas]}]
  {:query [{:input (comp/get-query IdeaInput)}
           {:ideas (comp/get-query IdeaList)}]
   :initial-state (fn [_] {:input (comp/get-initial-state IdeaInput {:id 1})
                           :ideas (comp/get-initial-state IdeaList {:id 1})})}
  (dom/div
    (ui-idea-input input)
    (ui-idea-list ideas)))

eoliphant 2020-10-25T17:54:43.427100Z

hmm. that looks correct. Does the database look correct when you load the page? something that has at least

eoliphant 2020-10-25T17:54:51.427300Z

{:input [:input/id 1]
 :input/id {1 {:input/id 1 :input/idea "A string"}}

Mr. Savy 2020-10-25T17:58:04.427800Z

ok I'm a bit late but I made a gist of the issue I mentioned earlier. link: https://gist.github.com/AlbertSnows/25c41d887ebe0eb01e9eea868a362ef6 The output is at the bottom, but as a recap essentially the issue is that my route component has two sub-components, A and B, but when the data is passed through it's getting B twice. I haven't been able to figure out why.

stuartrexking 2020-10-25T23:12:12.430200Z

Anyone aware of a bug when using Fulcro Inspect with Fulcro 3.4.3 where the database values in inspect don’t update. The underlying values are updated, but the way the db is rendered by FI doesn’t show the state changes. I can transact changes in the REPL, it’s just the db doesn’t update in FI. If I roll back to 3.0.3 it works fine.

stuartrexking 2020-10-25T23:15:33.431100Z

This sounds like the same issue @jlmr might be having above.

stuartrexking 2020-10-25T23:27:47.432900Z

If I compile and the install the extension locally everything works with 3.4.3. If I use the version of Fulcro Inspect from the Chrome Web Store, which was updated on 1 June 2020 but reports a version of 1.0.21 then it doesn’t work.

stuartrexking 2020-10-25T23:28:39.433300Z

When I compile and install locally the extension version is 3.0.2

stuartrexking 2020-10-25T23:28:52.433700Z

But Chrome Web Store version is 1.0.21

stuartrexking 2020-10-25T23:29:47.434Z

:man-shrugging:

tony.kay 2020-10-26T16:26:54.443100Z

I have not updated the one in the store because the new version breaks for old apps. I’ll update it at some point. Very busy

Michael W 2020-10-25T23:50:19.435400Z

@stuartrexking See https://github.com/fulcrologic/fulcro-inspect/releases/tag/chrome-3.0.0-RC1 as of 3.4.0 there is a new chrome extension that hasn't been pushed to the Chrome store yet.

stuartrexking 2020-10-25T23:50:56.435600Z

@michael819 Thank you.