can be used for persist rehydrate, purge the application store,
Today to benefit from all the features of redux is to have an SPA, so you have to provide a router. With redux-recovery one can take advantage of redux in a web page and do exactly what offers redux for a SPA. In addition, redux-recovery is simple to use, it has a simple and reliable approach.
To install the stable version:
npm install --save redux-recovery
This assumes you are using npm as your package manager.
import createStore from 'redux';
import ReduxRecovery from 'redux-recovery';
const reduxRecovery = new ReduxRecovery({
recordAction: true,
nbSavedActions: 10
});
const middlewares = [reduxRecovery.start];
const store = createStore(reducer, {...initialState},
applyMiddleware(...middlewares),
));
Force state persistence
:
store.dispatch({ type: 'PERSIST_STORE' });
Retrieve the persistence of the state
:
reduxRecovery.getPersistState();
Purge persisted store
:
reduxRecovery.getPersistState();
rehydrate the store
:
reduxRecovery.getPersistState();