insomnia/app/middleware/localstorage.js
2016-03-20 13:42:27 -07:00

15 lines
357 B
JavaScript

import {LOCALSTORAGE_DEBOUNCE_MILLIS} from "../constants/global";
let timeout = null;
export default (store) => next => action => {
let result = next(action);
clearTimeout(timeout);
timeout = setTimeout(() => {
localStorage['insomnia'] = JSON.stringify(store.getState(), null, 2);
}, LOCALSTORAGE_DEBOUNCE_MILLIS);
return result;
};