Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
toddself opened this issue Sep 1, 2016 · 3 comments

Comments

@toddself
Copy link
Collaborator

toddself commented Sep 1, 2016

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?

@yoshuawuyts
Copy link
Owner

@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?

@toddself
Copy link
Collaborator Author

toddself commented Sep 1, 2016

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 :(

@yoshuawuyts
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants