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
Find a way to improve reducers composition #457
Comments
The only way I've been able to make a The ability for the js combine works is by using the fact that JS objects are more loose, that they can be constructed partially, built without knowledge of other parts. The type-safety of Swift doesn't seem to lend itself to that ability. I'm not sure how one could implement this at all without making state non-optional, which in turn brings in a host of other requirements, (like moving default state out of reducers). To be honest, I'm quite partial to making state in reducers non-optional. It fits much more with Swift type safety. |
I'd prefer a non nil state as well, especially since it almost never is nil 👍 In practice, the first thing I do in the main reducer passed to the store is From the top of my head, I can think of the Store API to change to:
Once we have knowledge of an initial state, maybe it makes sense to just put in into the To be honest, I never understood the utility of |
Something that has always puzzled me is the fact that the reducer signature is I think we shouldn't assume that a slice of the store must always have a value, you can have a Being able to pass the initial state or a function that returns the initial state seems like the right thing to do, but I have to admit that I've always liked about ReSwift that reducers can auto initialize themselves. I would prioritize here a more correct typing, tho. |
@dani-mp Do you have made any progress on this or do you have a proposal for e.g. ReSwift 7 that we should discuss? I would be pro |
Currently, when you want to create a store, you need to pass all reducers like this:
It'd be great if we had something like https://redux.js.org/api/combinereducers to make this nicer.
The text was updated successfully, but these errors were encountered: