PersistStoreGate
PersistStoreGate can be used to save application state to external storage. The only one limitation is that this storage must have setItem and getItem methods in API.
const App = () => (
<EventrixProvider eventrix={eventrix}>
<PersistStoreGate eventrix={eventrix} loader={Loader}>
<div className='app'>
{...}
</div>
</PersistStoreGate>
</EventrixProvider>
);
import { Eventrix, connectPersistStore } from 'eventrix';
import exampleReceiver from './receivers/example';
const initialState = {
exampleCounterOne: 0,
exampleCounterTwo: 0,
exampleCounterThree: 0,
};
const eventsReceivers = [exampleReceiver];
const eventrix = new Eventrix(initialState, eventsReceivers);
const config = {
storage: localStorage,
storageKey: 'exampleData',
whiteList: ['exampleCounterOne'], // or blackList: ['exampleCounterTwo', 'exampleCounterThree']
};
connectPersistStore(eventrix, config);
export default eventrix;Last updated
Was this helpful?