Fork me on GitHub
#om
<
2017-03-09
>
peeja13:03:03

What's the :om.next/tables for? Does Om actually use it? It appears to only write to it.

gardnervickers14:03:58

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.

peeja14:03:58

Is that what ref is for? I thought transact!'s ref was entirely unrelated to React's notion of ref

gardnervickers14:03:05

I’m meaning ref as in the 3-arity usage in (transact! r ref tx)

peeja14:03:23

Right. That's not the "ref of a component", is it?

gardnervickers14:03:16

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.

peeja14:03:41

If I'm reading the code correctly, that's solely for your own use, and Om never sets it to anything on your behalf.

peeja14:03:05

I am not reading the code correctly. 🙂

peeja14:03:18

(Sneaky re-bound symbols…)

peeja14:03:18

What's a "union component"?

gardnervickers14:03:19

A component with a union query,

{:thing-a (om/get-query …)
 :thing-b (om/get-query …)}

peeja14:03:57

You're saying that a DashboardItem here doesn't correctly return its ident? https://github.com/omcljs/om/wiki/Queries-With-Unions#the-queries

peeja14:03:22

Ah, I understand now

peeja14:03:25

The children

gardnervickers14:03:30

The children won’t have ref in the env a mutation called using a child component.

peeja14:03:52

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

peeja14:03:19

Is there a reason that wouldn't work?

gardnervickers14:03:33

I was under the impression that you shouldn’t implement Ident on the children of a union.

peeja14:03:20

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.

peeja15:03:11

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?