insomnia/app/middleware/localstorage.js

15 lines
357 B
JavaScript
Raw Normal View History

2016-03-20 04:00:40 +00:00
import {LOCALSTORAGE_DEBOUNCE_MILLIS} from "../constants/global";
let timeout = null;
export default (store) => next => action => {
let result = next(action);
clearTimeout(timeout);
2016-03-20 20:42:27 +00:00
2016-03-20 04:00:40 +00:00
timeout = setTimeout(() => {
localStorage['insomnia'] = JSON.stringify(store.getState(), null, 2);
}, LOCALSTORAGE_DEBOUNCE_MILLIS);
return result;
};