Fork me on GitHub

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


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


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


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


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)


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?


@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


I'm using it with 0.6.0-rc


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


I'm still using 15.1.0. Works fine.


I should upgrade to 0.6.0 and 15.2.1, though.


@gniquil: It sounds like you desire reactions?


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?


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?


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


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