-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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
Same action for different state parts #1628
Comments
Speaking very generically, the couple main ways to handle this would be either wrapping your reducers to add some sort of additional distinguisher to the action constants, or adding an additional field to the actions that could be used. I actually just posted a comment about this sort of thing on another issue a few days ago, linking to several related discussions and libraries. See #1602 (comment). |
Thanks for the response, though it seems like I still need to restructure the state, as action also get data for suggest and saving it to ui state is like a huge hack that I will stuck on later :( |
Upd: Currently stopped at implementation with passing context. actions/suggest/suggest.js:
reducers/index.js:
reducers/suggest/suggest.js:
Probably there already is some similar way of getting the same result |
I think this is a really nice solution to the problem, without going into more advanced solutions like providers or adopting an Elm architecture. I'll be trying it out and see where I can get. Have you found any issues with it so far? |
Yeah, this is a good way to do it. We should add this to FAQ. |
@jcano it seems to be a rather simple solution so I suppose that'll work nice. Wrote just a piece of a project using it and everything seems to be fine. Maybe automating it using some custom reducers combiner would be even better. |
Let's roll up some discussion into #1785 so this can be acted on. Hopefully soon! 👍 |
Hey! (Warn: Rather new to Redux)
I have several forms on the same page that have inputs with suggests. So I thought I could possibly write abstract action creators for working with suggests:
and pass
suggest
reducer to different parts of the app reducer:If I dispatch a suggest action after onChange of any input triggers, I obviously get both suggests shown.
Is there any practice of specifying a part of the state for an action still keeping it abstract? Or maybe I should restructure the state somehow?
I've read this issue: #897 and those form examples were kinda close to the thing I'm trying to make. Still there is always a parent in these examples that must contain all of the inputs.
The text was updated successfully, but these errors were encountered: