Closed dkoontz closed 8 years ago
Just like views are composed into a single function of State -> Html Action
, update functions are composed into a single update function. Parent's ultimately control their children and the actions they receive.
This means that if you have an action that originates at the root of your app, such as a page view, and a component tree that looks like this:
+- Layout
+- Home
+- Posts
+- Post
then Layout
, Home
, and Posts
all have to pass this action in their update functions to the correct children, all the way down the tree to Post
. This architecture has the advantage that data-flow becomes clear and explicit in the application code, and most importantly components become truly modular because they do not need to know anything about their parents. The drawback is that passing actions down the tree can be seen as cumbersome or boilerplate.
If you don't want to pass "global" actions down the tree, one approach is to create a wrapper that does this for you, à la pux-undo.
Sorry I never replied, this cleared things up thanks!
I'm trying to figure out how to translate some Javascript architecture into Pux / Purescript. This is for a desktop application using Electron. I have in several places UI events that fire off Async events that are currently observed by several different components via Flux store change emit events. I was thinking that the extra inputs array that can be provided to a component could possibly be used for this, but the
action
type for all the signals must be the same so that they can be merged. I could expose a global signal and then wire up Signal.runSignal somewhere via FFI but that feels pretty messy. Do you have any idea how I could provide a global events signal that can be used by my async background processes to signal progress/success/failure to all the components that would need it? Is there perhaps a better way to do what I'm going for that doesn't require components up the chain to be explicitly aware of the data needed by components down the chain?