Add localstorage helper

This commit is contained in:
fragosti
2018-05-25 12:02:45 -07:00
parent b0e6ce581a
commit 9631927a8c

View File

@@ -0,0 +1,16 @@
import { localStorage } from 'ts/local_storage/local_storage';
import { INITIAL_STATE, State } from 'ts/redux/reducer';
const STORAGE_NAME = 'persistedState';
export const stateStorage = {
saveState(partialState: Partial<State>): void {
localStorage.setObject(STORAGE_NAME, partialState);
},
getPersistedState(): Partial<State> {
return localStorage.getObject(STORAGE_NAME);
},
getPersistedDefaultState(): State {
return { ...INITIAL_STATE, ...stateStorage.getPersistedState() };
},
};