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.
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.
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?
ah, yes
honestly I think a component-just-for-its-query with a pre-merge is actually pretty elegant in its own right
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!Those things are indeed in the db
Did you compose that input to the root?
initial state and query have to compose to root
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:<code>(defsc IdeaInput<br /> [this {:input/keys [idea]}] <br /> {:query [:input/id :input/idea]<br /> :ident :input/id<br /> :initial-state (fn [{:keys [id]}]<br /> {:input/id id<br /> :input/idea "A string"})}<br /> (dom/div<br /> (dom/label "Idea: ")<br /> (dom/input {:value idea<br /> :onChange #(m/set-string!! this :input/idea :event %)})))</code>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?
I’ve tried that already and it didn’t change anything
In reply to @slackt03rzgpfr=2du56r03vn_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
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
@kevin842 sorry, wasn’t at my desk. Transaction looks like this: (com.fulcrologic.fulcro.mutations/set-props {:input/idea "A stringa"})
When I add an a
to the string in the input
However in the transactions tab, the details for this transactions show:
Diff added
nil
Diff removed
nil
Maybe look at the code of the mutation, what it actually does? Add some logs to it?
@holyjak the code for the mutation is provided by fulcro. Pretty sure it is the generated by mutations/set-string!!
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
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)))
hmm. that looks correct. Does the database look correct when you load the page? something that has at least
{:input [:input/id 1]
:input/id {1 {:input/id 1 :input/idea "A string"}}
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.
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.
This sounds like the same issue @jlmr might be having above.
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.
When I compile and install locally the extension version is 3.0.2
But Chrome Web Store version is 1.0.21
:man-shrugging:
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
@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.
@michael819 Thank you.