untangled

NEW CHANNEL: #fulcro
2016-08-11T21:30:15.000373Z

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?

2016-08-11T21:30:56.000374Z

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}}))

2016-08-11T21:31:00.000375Z

vs.

2016-08-11T21:31:15.000376Z

(fn [_]
     (toggle-view :departments)

tony.kay 2016-08-11T21:31:22.000377Z

what is toggle-view?

2016-08-11T21:31:28.000378Z

first one throws, second one doesn't

2016-08-11T21:31:35.000379Z

toggle-view is a mutation

tony.kay 2016-08-11T21:31:41.000380Z

how? There is no component

tony.kay 2016-08-11T21:31:43.000381Z

to transact on

2016-08-11T21:31:48.000382Z

#(om/transact! this [(report/set-survey-view ~{:view %})])

tony.kay 2016-08-11T21:32:09.000384Z

what is "this", and is it the same "this" as the visible "this"?

2016-08-11T21:32:15.000385Z

yes

2016-08-11T21:32:31.000386Z

this is the current component on the screen

tony.kay 2016-08-11T21:32:43.000387Z

for toggle-view?...how?

tony.kay 2016-08-11T21:33:00.000389Z

oh, is it earlier in a let, or something?

2016-08-11T21:33:19.000390Z

yeah, so a more complete sample

tony.kay 2016-08-11T21:33:55.000391Z

is toggle view causing the component to disappear?

2016-08-11T21:34:18.000392Z

(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")))

tony.kay 2016-08-11T21:34:20.000393Z

(from the dom)

tony.kay 2016-08-11T21:34:57.000394Z

or otherwise change a union query to no longer contain the rendering component

2016-08-11T21:34:58.000395Z

it’s causing a different function to be called, but is rendering the same component

2016-08-11T21:35:17.000396Z

as in, different branch of dom nodes to be rendered

2016-08-11T21:35:22.000397Z

but same component

2016-08-11T21:35:37.000398Z

and, when there is no data fetch, it works just fine

tony.kay 2016-08-11T21:37:01.000399Z

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?

2016-08-11T21:37:43.000400Z

yes it does

2016-08-11T21:37:49.000401Z

shows a loading marker if the data hasn’t been loaded yet

tony.kay 2016-08-11T21:39:06.000403Z

are you stomping on something that is already at :reports/executive-report?

tony.kay 2016-08-11T21:39:18.000404Z

try loading to a diff key

tony.kay 2016-08-11T21:39:51.000405Z

in other words, try to isolate it to the fact that there are 2 transacts, or the fact that the data is the problem

tony.kay 2016-08-11T21:39:58.000406Z

I suspect the latter

2016-08-11T21:40:12.000407Z

ok, thanks

2016-08-11T21:41:00.000408Z

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

2016-08-11T22:04:47.000409Z

We don't really use load-data directly very often

2016-08-11T22:05:26.000410Z

Generally we use a named mutation with df/load-data-action instead.

2016-08-11T22:06:47.000411Z

Then we can do something like:

#(om/transact! this `[(report/set-survey-view ~{:view %})
                                               (executive-report/reload %)])]

2016-08-11T22:11:49.000412Z

I think we needed to do that to avoid the above kind of error you describe, but I don't recall for sure

2016-08-11T22:18:10.000413Z

@therabidbanana: thanks, that’s interesting i’ll give that a try

2016-08-11T22:22:17.000414Z

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

👍 1
2016-08-11T23:17:56.000415Z

@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