Created
September 26, 2019 05:10
-
-
Save mbret/511edf9627b743ad8a52559be61e3d45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// we have a LOGOUT action that will reset the whole state | |
// HACK: When state is recreated, it will loose '_persist' in it, and the state will not be persisted anymore. | |
// Dispatching 'persist/REHYDRATE' makes persistence work again somehow, so we dispatch it to all persisted keys. | |
const storageKeys = yield call(storage.getAllKeys); | |
const persistKeys = (storageKeys.map((key: string) => { | |
const regexp = new RegExp('^persist:(.+)'); | |
if (key.match(regexp)) { | |
return RegExp.$1; | |
} | |
return ''; | |
}) as string[]).filter(key => key !== ''); | |
const persistActions = persistKeys.map(key => put({ | |
type: 'persist/REHYDRATE', key, payload: undefined, | |
})); | |
yield all(persistActions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment