ngxs-labs / immer-adapter

:hamster: Declarative state mutations
MIT License
46 stars 10 forks source link

Can't reset state returning 'defaults' or an object with the type of the state #227

Closed luthor77 closed 5 years ago

luthor77 commented 5 years ago

I'm trying to reset my state, but I can't. I could use 'this.store.reset(State)', but sometimes I want to wait in somewhere by the action dispatched. And sometimes I want to reset everything except by one attribute. If the state has too many attributes it's easier create a function to assign each attribute to its default.

But the easiest would be just "return defaults", or "return { ...defaults, attribute: draft.attribute } as StateModel"

Here is the stackblitz exemple: https://stackblitz.com/edit/angular-c2nszw

splincode commented 5 years ago

@luthor77 thank you for reporting

https://github.com/ngxs-labs/immer-adapter/pull/232

luthor77 commented 5 years ago

Thanks for the fast fix.

splincode commented 5 years ago

We can use immer-adapter v3.0.4 now