-
Notifications
You must be signed in to change notification settings - Fork 220
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
Question on how to use the reducer right way #240
Comments
hi @brianegan. Did you get a chance to review this, please? It would be great if you could check it will help me a lot these days. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am working on redux for state management and using MVVM architecture. I have made a generic reducer that only returns the updated store. For each feature I make a class, let’s call it a sub-store, and make this class in AppStore as a data member to maintain its own state. Now for each sub-store, I made a reducer that extends the generic reducer for common operations. My generic reducer takes the old sub-store and takes the new sub-store as action and depending on the API state e.g. (‘isLoading’, ’success’), updates the store. Since reducers are supposed to have logic. I am processing and calculating the new sub-store state either in thunkAction or in ViewModel and dispatching the Action only when the new sub-store is ready to be updated. Let's say I want to update the data member
isNewUser
. I will do this in ThunkAction:Am I doing it right? In this way, the reducer does not have much logic despite some specific functionalities that may be required by a specific sub-store.
As it can be seen in the above snippet I created an instance of UserLoginStore and kept the updated store in that and then dispatched the action to the reducer where the actual state will be updated for the application.
The text was updated successfully, but these errors were encountered: