Fork me on GitHub
#rum
<
2017-06-03
>
levitanong05:06:52

@martinklepsch I’m using your derivatives library, (great stuff btw) and I was wondering: is there an idiomatic way to access derivative data on the root component? AFAIK, the root component is just there to establish the child contexts, and only the descendant components can get the data.

martinklepsch05:06:07

@levitanong Hm. I haven’t tried and I’m not sure if react supports that. Can you explain why you need it?

levitanong05:06:05

@martinklepsch Just trying to manage the number of components I’m using. 😛 I’m trying to make sente (the websockets library) only initialize when the user logs in with a specific host. Not as straightforward a path as I had hoped.

levitanong05:06:05

@martinklepsch I’m also considering putting in the websocket event channel in the db-atom, even though I have this very strong feeling this is probably not a good thing to do.

martinklepsch05:06:34

@levitanong my intuition would be to handle the initialization as part of the event rather than as part of a subscription?

martinklepsch05:06:41

I think putting the websocket channel into the db-atom isn’t wrong to do, I’d just try to make sure to isolate it from the rest of your domain data in the db

levitanong05:06:07

@martinklepsch That was my thought too, so I kept it in my event loop (similar to redux and om-next, i guess) but then I had to put the return value… somewhere. And I only have access to the app state (the derivatives db) from the event loop, so…

levitanong05:06:21

Okay, this gives me some comfort.

levitanong05:06:58

Thanks so much for your advice, @martinklepsch!

levitanong06:06:50

@martinklepsch Another question. 😄 Say I want to use some derivative information in a lifecycle method like will-update. How would I use it? Still d/react?

martinklepsch06:06:08

@levitanong if that complains because it’s not in a render method you can use (deref (d/get-ref state :drv-key))

levitanong06:06:34

I haven’t tried d/react yet, because I’m still struggling with CORS. Just thinking ahead. the get-ref looks like the right way to go! Thanks muchly, man!

martinklepsch07:06:44

Not sure if d/react will just work but get-ref + deref should work fine 🙂

martinklepsch07:06:28

Looking at the rum code using react probably won’t work as the *reactions* binding isn’t present in other lifecycle hooks than render