insomnia/app/actions/global.js
2016-03-20 13:42:27 -07:00

24 lines
539 B
JavaScript

import * as types from '../constants/actionTypes';
import {LOCALSTORAGE_KEY} from "../constants/global";
export function restoreState () {
return (dispatch) => {
setTimeout(() => {
let state = undefined;
try {
state = JSON.parse(localStorage[LOCALSTORAGE_KEY]);
} catch (e) { }
dispatch({type: types.GLOBAL_STATE_RESTORED, state});
}, 0);
}
}
export function loadStart () {
return {type: types.GLOBAL_LOAD_START};
}
export function loadStop () {
return {type: types.GLOBAL_LOAD_STOP};
}