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

New Feature method for reset to intial state. #38

Closed
wants to merge 1 commit into from

Conversation

idnjoni
Copy link

@idnjoni idnjoni commented May 27, 2020

For the development of a custom middleware that persists the store over a page reload, a method to reset the states to their initial value is required. e.g. a LogoutAction should reset most of the store to its intial state

For the development of a custom middleware that persists the store over a page reload, a method to reset  the states to their initial value is required. e.g. a LogoutAction should reset most of the store to its intial state
@mrpmorris
Copy link
Owner

In each state have a static readonly field named Empty, which is what you default for state to.

In your reducers replace the state with Empty when a signout action is dispatched.

@mrpmorris mrpmorris closed this May 27, 2020
@idnjoni
Copy link
Author

idnjoni commented May 28, 2020

My intention was not to bypass the reducers. I wrote a Fluxor middleware to persist the store, similar to the solutions for react redux.
The middleware is based on your implementation of the ReduxDevTools middleware.

I would like to publish this project in NuGet when I have cleaned up the code and all features are implemented.
If you want you can take a look at the sources here https://github.com/idnjoni/DevTestFluxorBlazorServer.

I understand that you want to avoid creating opportunities to bypass the reducer. But in this case the reset should be done from the middleware, and this would require the change from the pull request.

For the few states that should not be reset, I want to implement a new class attribute similar to the "NoPersist" attribute.

What do you think?

@mrpmorris
Copy link
Owner

It looks interesting.

You could have a requirement for your users to implement an interface on their state to return a default state, and then call that yourself if it is implemented.

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

Successfully merging this pull request may close these issues.

None yet

2 participants