2016-10-17 10:39:11 +13:00
|
|
|
|
|
|
|
|
const localstorageMiddleware = (function(){
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The actual middleware inteceptor
|
|
|
|
|
**/
|
|
|
|
|
return store => next => action => {
|
|
|
|
|
|
|
|
|
|
// proceed as normal first
|
|
|
|
|
// this way, any reducers and middleware do their thing BEFORE we store our new state
|
|
|
|
|
next(action);
|
|
|
|
|
|
|
|
|
|
// get the state, and plug it in to our localStorage
|
|
|
|
|
var state = store.getState();
|
2016-10-18 08:56:53 +13:00
|
|
|
//localStorage.setItem('state', JSON.stringify(state));
|
2016-10-17 10:39:11 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
export default localstorageMiddleware
|