What's the :om.next/tables
for? Does Om actually use it? It appears to only write to it.
Is there a way to get the ref
of a component for a child in a union component? Normally this is accessible through ref
from the env
in a mutation, but with union children not having ident
’s, I don’t see this being set.
Is that what ref
is for? I thought transact!
's ref
was entirely unrelated to React's notion of ref
I’m meaning ref
as in the 3-arity usage in (transact! r ref tx)
Right. That's not the "ref of a component", is it?
I’m not sure if it’s also used to set the react-ref for a component’s DOM node, but for my question I’m wondering how to go about getting the ident
of children in a union component. With other components that implement Ident
it seems that the components ident
is passed in the mutation env
as ref
.
Is it? The only place I see a ref
being passed in is https://github.com/omcljs/om/blob/master/src/main/om/next.cljc#L1585-L1586
If I'm reading the code correctly, that's solely for your own use, and Om never sets it to anything on your behalf.
https://github.com/omcljs/om/blob/master/src/main/om/next.cljc#L1496-L1499
I am not reading the code correctly. 🙂
(Sneaky re-bound symbols…)
What's a "union component"?
A component with a union query,
{:thing-a (om/get-query …)
:thing-b (om/get-query …)}
You're saying that a DashboardItem
here doesn't correctly return its ident
? https://github.com/omcljs/om/wiki/Queries-With-Unions#the-queries
Ah, I understand now
The children
Yup
The children won’t have ref
in the env a mutation called using a child component.
I haven't done much with unions, but I had it in my head that the children would have the idents, not the component that unions them
Is there a reason that wouldn't work?
I was under the impression that you shouldn’t implement Ident
on the children of a union.
That does appear to be how the docs do it. But if that's true, I can't imagine how you'd get around the problem you're seeing.
I'm still having trouble working out how to best query for data when I have a path to the data rather than just a single ID. For instance, let's say I'm rendering the URL /person/123/pet/George
. 123
is a unique person ID, but the name George
is only unique among a single person's pets, so I need both pieces of information to address the pet.
I can make the remote query send pretty easily, getting my parser to compute a query like:
'[{(:root/person {:person/id 123})
[:person/name
{(:person/pet {:pet/name "George"})
[:pet/id
:pet/name
:pet/height
:pet/weight]}]}]
But then I still need to store the result in the app state in a way that lets me query the pet by person and name, or the data will never be delivered to my component. I'm considering a form like:
{:root/person {{:person/id 123} [:person/by-id 123]}
:person/by-id {123 {:person/name "Hugo"
:person/pet {{:pet/name "George"} [:pet/by-id 456]}}}
:pet/by-id {456 {:pet/id 456
:pet/name "George"
:pet/height 23
:pet/weight 3.1}}}
This means doing a good deal of custom parser work (mostly or entirely throwing away db->tree
) and a good deal of custom merge
work as well.
Am I on the right track here? Or am I off in the weeds? Is there an easier, intended way to do this?