has anyone ever run into a situation where they have a mutation that otherwise works, but when it’s paired with a call to load-data
, causes a “no queries for component path” error from om?
e.g.
(fn [_]
(toggle-view :departments)
(df/load-data this [:reports/executive-report]
:post-mutation 'colocate-executive-report
:params {:reports/executive-report {:survey-id id}}))
vs.
(fn [_]
(toggle-view :departments)
what is toggle-view?
first one throws, second one doesn't
toggle-view is a mutation
how? There is no component
to transact on
#(om/transact! this [(report/set-survey-view ~{:view %})])
what is "this", and is it the same "this" as the visible "this"?
yes
this
is the current component on the screen
for toggle-view?...how?
oh, is it earlier in a let, or something?
yeah, so a more complete sample
is toggle view causing the component to disappear?
(render [this]
(let [toggle-view #(om/transact! this `[(report/set-survey-view ~{:view %})])]
(dom/button #js {
:onClick (fn [_]
(toggle-view :departments)
(df/load-data this [:reports/executive-report]
:post-mutation 'colocate-executive-report
:params {:reports/executive-report {:survey-id id}}))}
"Button text")))
(from the dom)
or otherwise change a union query to no longer contain the rendering component
it’s causing a different function to be called, but is rendering the same component
as in, different branch of dom nodes to be rendered
but same component
and, when there is no data fetch, it works just fine
I understand that, but load data happens on a different time scale. toggle-view happens immediately, and then a rerender is scheduled. Does the new view rely on data that is to-be-supplied by the load?
yes it does
shows a loading marker if the data hasn’t been loaded yet
are you stomping on something that is already at :reports/executive-report?
try loading to a diff key
in other words, try to isolate it to the fact that there are 2 transacts, or the fact that the data is the problem
I suspect the latter
ok, thanks
pretty sure i’m not stomping on data, but i’ll try to see how the data or the post processing might be mucking with something it shouldn't
We don't really use load-data directly very often
Generally we use a named mutation with df/load-data-action
instead.
Then we can do something like:
#(om/transact! this `[(report/set-survey-view ~{:view %})
(executive-report/reload %)])]
I think we needed to do that to avoid the above kind of error you describe, but I don't recall for sure
@therabidbanana: thanks, that’s interesting i’ll give that a try
Added benefit - it made it really easy to build routing - we model HTML5 history events as just transactions on the reconciler, so having load data mutations makes that system work pretty well
@tony.kay: just fyi, the solution @therabidbanana describes above did fix the problem. Not sure if that is necessarily untangled’s design intention, if this is a bug, or if it’s just a function of how om is scheduling renders