Fork me on GitHub
#reagent
<
2016-10-13
>
gniquil03:10:28

hey guys, I’m using reagent but would like to know if there’s an idiomatic way to trigger actions in a series of nested components

gniquil03:10:14

for example, if compA contains compB contains compC, upon url change, I’d like to have compC first run a function, then compB, then compA

gniquil03:10:54

and also the other way around, i.e. when URL changes, compA run a func, then compB, then compC

gniquil03:10:01

i know that with nested component, one can create a function, as pass it as “props” to the nested component, then upon some action, the nested component can run a func, inside of which it calls the parent’s func

gniquil03:10:57

however, this method only works when the action is a button click or something that’s inside the nested action, what if I have a global side-effecting action (like URL change, or some websocket channel receives new data)

gniquil03:10:26

i guess potentially the global side effecting thing could potentially push the data into a channel, and the inner nested component just “takes” from that channel and trigger the action?

sandbags08:10:22

@mikethompson this has encouraged me to redesign my CES to reduce some complexity in the data structure in return for making the API code a little more complex, this is good

miikka11:10:47

I'm using it with 0.6.0-rc

curlyfry11:10:26

@miikka And it works well? What version of cljsjs/react-with-addons are you using?

miikka11:10:10

I'm still using 15.1.0. Works fine.

miikka12:10:54

I should upgrade to 0.6.0 and 15.2.1, though.

reefersleep14:10:32

@gniquil: It sounds like you desire reactions?

reefersleep15:10:48

In any case, it sounds like you want to depend on some global side-effecting change. When this occurs, put some new data into a globally available r/atom which your components read from, then perform your calculations inside your components based on that read. I guess? I can't figure out from your description whether your problem is trivial or hard 🙂 Maybe you could approximate the problem in a code example?

sandbags18:10:58

If I am using the 2 fn version of reg-sub is it okay to refer to re-frame.db/app-db as one of the signals I return?

sandbags18:10:10

I can’t see why not as the default function is reaching in and returning it

mikethompson22:10:53

note: there is a specific #re-frame channel which is very active. These questiosn might be best asked in there