Akita: Resetting all stores to initialState at once.

Created on 2 Nov 2018  路  5Comments  路  Source: datorama/akita

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[X] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior


I have to call .update(createInitialState()) for each store instance.

Expected behavior


A way to access the Akita instance and to reset the entire store to initial state.

What is the motivation / use case for changing the behavior?


There is no easy way to reset all Akita stores at once,
common use case is when a user wants to logout.

enhancement

Most helpful comment

@DanielNetzer I was thinking about something like:

import { resetStores } from '@datorama/akita';

resetStores({ exclude: ['storeName'] });

All 5 comments

Yes, It's a helpful suggestion. I need to think about the API.

... yep, it looks like a helpful functionality.

@DanielNetzer I was thinking about something like:

import { resetStores } from '@datorama/akita';

resetStores({ exclude: ['storeName'] });

looking great, I can make a PR if you don't mind.

Go for it.

Was this page helpful?
0 / 5 - 0 ratings