om

Please ask the channel first, not @dnolen directly!
peeja 2017-03-09T13:32:03.300371Z

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

gardnervickers 2017-03-09T14:25:58.856784Z

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.

peeja 2017-03-09T14:30:58.917407Z

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

gardnervickers 2017-03-09T14:32:05.931268Z

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

peeja 2017-03-09T14:32:23.935270Z

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

gardnervickers 2017-03-09T14:37:16.997537Z

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.

peeja 2017-03-09T14:39:05.021332Z

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

peeja 2017-03-09T14:39:41.028498Z

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

peeja 2017-03-09T14:40:05.033439Z

I am not reading the code correctly. 🙂

peeja 2017-03-09T14:40:18.036134Z

(Sneaky re-bound symbols…)

peeja 2017-03-09T14:41:18.048683Z

What's a "union component"?

gardnervickers 2017-03-09T14:43:19.075202Z

A component with a union query,

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

peeja 2017-03-09T14:44:57.095595Z

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

peeja 2017-03-09T14:45:22.100689Z

Ah, I understand now

peeja 2017-03-09T14:45:25.101368Z

The children

gardnervickers 2017-03-09T14:45:27.101850Z

Yup

gardnervickers 2017-03-09T14:45:30.102504Z

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

peeja 2017-03-09T14:46:52.121093Z

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

peeja 2017-03-09T14:47:19.127223Z

Is there a reason that wouldn't work?

gardnervickers 2017-03-09T14:50:33.167497Z

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

peeja 2017-03-09T14:53:20.204001Z

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.

peeja 2017-03-09T15:34:11.767961Z

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?