Fork me on GitHub
#om
<
2017-03-06
>
baptiste-from-paris09:03:38

hello guys, little React/om question - consider this react-native component in js :

const AppText = ({ children, style, …rest}) => (
  <Text style={[globalStyles.COMMON_STYLES.text, style]} {…rest}>
    {children}
  </Text>
);
How do you find this om translation :
(defui AppText
  Object
  (render [this]
    (let [[{:keys [children style]} & rest] (om/props this)]
      (text (merge {:style style} rest)
            children))))

(def app-text-comp (om/factory AppText))

danielstockton16:03:10

Is it a valid approach to include namespaced keywords in a query and filter them out of the ast in the parser, before sending to remote? Something is going wrong somewhere... Would it be preferable to filter out those keys on the backend?

wilkerlucio16:03:58

@danielstockton I think it is, and actually, Untangled does just that with the ui namespace

wilkerlucio16:03:20

I think it's preferable to filter on the client, this way you can avoid wasted bytes on the network

danielstockton16:03:38

I copied untangled using ui too. ast looks good but it seems to have broken my query somewhere

danielstockton16:03:07

I updated query and children on the ast

foobar17:03:10

Using om.next, I want to change the query for an instance of a sub component

foobar17:03:31

Any recommendations about how to get a reference to it?

foobar17:03:59

What do I actually need to pass to om.next/subquery for example?

levitanong17:03:05

@foobar if you want to change the query, there is om/set-query! and om/update-query!. A common gotcha is the component/class confusion. For both set-query! and update-query!, you’d need to use the component instance. (usually this)

foobar17:03:03

I'm stuck on how I would obtain a ref for the component

foobar17:03:34

I am trying this from outside the component right now, so I would like to get a ref from the reconciler

levitanong18:03:49

@foobar if you have access to the reconciler, I would do something like this: (om/class->any reconciler SomeComponent)

foobar18:03:42

I did that, but "refs" for my root component is empty

foobar18:03:57

I am using a datascript db for my state

anmonteiro18:03:57

@foobar if you’re using DataScript you’re not gonna be able to use set-query! so it’s kinda pointless to solve the ref problem

foobar18:03:38

Ok, I don't understand om next 😞

foobar18:03:23

I was assuming that I could change the query for my component and have my read function doing the lookup in the datascript db

anmonteiro18:03:19

you can change the query for your component, just not with DataScript. that’s a current limitation https://github.com/omcljs/om/issues/834

foobar18:03:24

Do you have any thoughts about this?

foobar18:03:48

If I only care about using datascript is it easy to hack om next for this to work?

foobar18:03:33

I'm just curious why this isn't fixed already. Or are you just waiting for someone to PR?

anmonteiro18:03:15

@foobar you can use DataScript right now provided you don’t use dynamic queries

anmonteiro18:03:38

the issue is easy to solve once we have a plan on where to store the component queries

levitanong18:03:53

@foobar is there any reason why you want to use a query? You can just store it as application state.

levitanong18:03:09

*query param

levitanong18:03:40

oh wait, you never said you were using query params

levitanong18:03:09

although i can’t imagine why else you’d want to use set-query!.

foobar18:03:13

Please could you describe how the component 'tree' works at the moment? Is there actually such a thing? I guess that they way I would do it is to add a parameter to the reconciler and pass it a function to use to resolve components. For me it would seem that If I could construct a component with a unique ident I could use that in the function I supply to lookup a ref to the component. In a similar way creating an instance of a component could also call a user supplied function and add itself to whatever the users representation of the component tree is.

foobar19:03:18

I wanted to dynamically create a child component. Adding the data to the (Datascript) state is simple. Updating the query of that state so that the relevant component knows it has a new child is not trivial.

foobar19:03:06

If set-query worked then one could change the parents query so that the data can be passed to the new child

levitanong19:03:35

@foobar Hang on, I’m busy at the moment, will get back to you when I can. Though I think @anmonteiro is ultimately more qualified to help you. 😉

7h3kk1d19:03:23

Is https://www.youtube.com/watch?v=MDZpSIngwm4 david’s most recent om next talk?

levitanong20:03:37

Just watched it. That was a damn good talk.

7h3kk1d20:03:59

dnolen’s talks are hickeyesque for me

levitanong20:03:44

7h3kk1d: I initially read this as “Hick eyes que” Whatever that means. lol

7h3kk1d20:03:10

I’m trying to think of a clever retort but it’s not coming.