ng-turkey/ngxs-reset-plugin

A possibility to reset to default all states except some states

beaussan opened this issue · 2 comments

Is your feature request related to a problem? Please describe.

When an user logout, I want to keep some state (for example preference of UI) and reset back to default all other states. And unless I dispatch a StateReset with all my states, I am not able to do that.

Describe the solution you'd like

I would like an action to dispatch in order to reset all state excepts some states.

Describe alternatives you've considered

Dispatch a StateReset with all active states, but I don't think it's the best solution.

Hi @BEAUSSART

First of all, thanks for all your support to this project. This was a very useful and challenging feature request for us.

It was a tricky action to create, because no public APIs were provided by NGXS store from which a list of all state classes or a tree of complete meta data could be taken. We had to add a handler and a basic service to get the initial state on app initialization and use it when the action is dispatched later on.

A PR has just been merged addressing the issue. All our tests have passed, so we are planning to release a minor version soon.

Enjoy, and thanks again for the idea!

Note: Lazy loaded states are not handled in this version. If you have any, you may need to use the action cautiously. This caveat is documented in the manual.

v1.1.0 is released and published to npm.