Fork me on GitHub

I have an Indexer question. Can someone help me?


@akiel ask your question and we'll see


If I have a list of items were each item is a component with om/Ident, I can find the individual component rendering one particular item with (om/ref->components r <ident>). So far so good.


But if I render only one item (say in a detail view) in the same manner, I can’t find the component with the items ident.


Instead of that, the ident under which the component is indexed is [:my-item nil].


And my question is: why is there a difference? At the end I have an issue with re-rendering on new data from remote. And I think it’s related to the fact that the reconciler can’t find the component to re-render because it’s only indexed under [:my-item nil] and not under [:my-item <id>].


I realize that if you want to call multiple transactions, you’re supposed to list them all under the same call to transact! like so:

(om/transact! this [(tx/first) (t/second {:some :params})])
I’ve noticed that if, instead, you make multiple calls to transact! in quick succession, it can cause a console error:
(om/transact! this [(tx/first)])
(om/transact! this [(tx/second {:some :params})])
;; => “No queries exist for component path …” error displays in the console
Anyone have insight into why that might be happening? I know that transact! schedules re-renders, but shouldn’t the behavior of these two code samples be identical?


@akiel: are you sure that the id exists for that component? it isn’t being overwritten by the server somehow? or being pulled improperly from app state?


@ethangracer: my server returns {<ident> <data>} but the reconciler can’t find a component which has the ident as ref.


Do you have an example in your application were you query a remote for an ident? I can’t find such examples.


I do, unfortunately it’s for work so I can’t share


but the gist is [{[:todo/by-id 5] [:title :done?]}]


@ethangracer: regarding your transactions: I can’t say something about your problem but usually I would try to merge mutations into one trasnaction.


and it does successfully merge that data back


yes in my case the data is also sucessfully merged, but no re-render is done


is the component that you’re trying to re-render already on the screen?


to my knowledge the indexer only keeps track of currently rendered components


yes the component is already rendered with partial data - let me explain


I have a list of items which queries only a subset of the items data. Than I click on one item which renders a component showing more data of this item. First it’s rendered with the subset of the data already available in the state. Than the remote query is issued. The remote answers with the full data which is sucessfullt merged. But no re-render is done.


I have debugged the reconciler and it just can’t find a component which the appropriate key.


@ethangracer: I found my problem. I just forgot to query for my item’s id so the ident returned was [:my-item nil]. It’s just super easy to make such simple mistakes not noticing it… 😟


that’ll do it. definitely been there, it’s hard to catch those.


There is already a warning if one returns invalid idents but that doesn’t check for nil id values. I think I’ll suggest an addition.