yoshuawuyts / barracks

:mountain_railway: action dispatcher for unidirectional data flows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why is the namespace or "send caller" not exposed on the onStateChanged hook?

toddself opened this issue · comments

In trying to wrap Barracks in component that I could use as an action dispatcher/store for React, I wanted to notify a specific component that it's state had changed (using a namespace per component).

However, the hook for state changing strips off the namespace and just provides the action being invoked. I'm doing some real bad zalgo-state-management to attempt to capture the component name but i feel it would be easier if I could get the namespace in that hook.

It looks like a breaking change to barracks though (I haven't looked into choo for this), so I'm wondering:

a. should it return the namespaced action as caller
b. return caller and namespace as separate variables
c. is this just a bad idea™ and I should figure out a different way to do it?

commented

@toddself the way I'd approach this is ditch react's notion of state all together and only use props - that should give you the same semantics as choo for everything but the view engine itself. E.g. actions modify the state, whenever state is updated new props are flushed down. No need to link stuff.

That's actually the main intent behind rooch - what are we missing there for it to work for you?

Even if I'm updating props vs state, if I update it post model-state-change, I still need to be able to notify the component after the fact. Rather than use the choo-system for explaining when the DOM requires an update I was trying to rely on the native React system (by forcing a change to either state or props back on the component).

I could update it on the way out of the component to the data store but that feels wrong :(

commented

I think with top down passing of props + https://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate you should be good (: