Fork me on GitHub
#om
<
2016-11-22
>
danielstockton12:11:47

If I have a component (sidebar) which should set-query on another component (main view) in order to change filters, how should i pass the main component to the sidebar component?

danielstockton12:11:04

The sidebar component is actually a child component of the main view, I don't know if I can access the parent component somehow?

anmonteiro12:11:54

@danielstockton pass it as a computed property

anmonteiro12:11:11

(sidebar (om/computed sidebar-props {:owner this}))

danielstockton12:11:27

Ok, thought about doing that but wasn't sure if it was a good idea or not, thanks

danielstockton12:11:47

It's actually a queryless component, does that mean I can just pass it as props?

danielstockton12:11:38

I also have some code I'm worried about in my send function, I'm using the current compassus route to find the component for that route, and using that component with om/tree->db to normalize what I get back from a remote call. Does this sound very wrong?

danielstockton12:11:17

I tried getting the component from the query ast, but it seems to be a child component there that only has a query fragment and to use tree->db i need the root query

anmonteiro12:11:55

@danielstockton hrm, if you pass the query to normalize against in the send callback, Om will normalize it automatically for you

anmonteiro12:11:08

provided you have :normalize true in the reconciler

danielstockton12:11:52

oh, i didn't see that took a second argument

danielstockton12:11:14

wow, worked, thanks

danielstockton12:11:52

quite a big trick i was missing

danielstockton13:11:04

`[({:items ~subquery} {:test ?test})]))
I have a parameterized query like this and I can't work out how to quote it, so that the ?test is replaced and I don't just send the symbol

danielstockton13:11:26

ah, reason being that it shouldn't qualify the namespace right?

danielstockton13:11:40

just want a plain symbol matching the key in IQueryParams

kardan14:11:17

Anyone have a pointer to a small project with Om.next and some server side stuff (maybe even not a Datomic db but a backing sql db) ?

danielstockton14:11:38

what's the om.next way to set a component's initial state?

danielstockton14:11:04

set-state! in willmount?

tobiash18:11:05

@anmonteiro: When using compassus, which component can I use as my root component, when using merge! or tree->db? I tried (compassus/root-class app), but that does not seem to have a query attached to it

danielstockton19:11:31

@tobiash I started by using the routes to deduce the root component from the current root. Then i discovered that the send callback takes an optional second argument (a query) and om can do this for you with the default merge.