diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-05-26 03:02:45 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-05-26 03:03:18 +0800 |
commit | 9631927a8cbbc739f1e1d0d574c61e19803ee0dc (patch) | |
tree | f291e1882b9209a19540fb2652e8a686df725550 /packages/website/ts/local_storage | |
parent | b0e6ce581a77d752d4a0b7f025237c4ac0aee010 (diff) | |
download | dexon-sol-tools-9631927a8cbbc739f1e1d0d574c61e19803ee0dc.tar.gz dexon-sol-tools-9631927a8cbbc739f1e1d0d574c61e19803ee0dc.tar.zst dexon-sol-tools-9631927a8cbbc739f1e1d0d574c61e19803ee0dc.zip |
Add localstorage helper
Diffstat (limited to 'packages/website/ts/local_storage')
-rw-r--r-- | packages/website/ts/local_storage/state_storage.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/website/ts/local_storage/state_storage.ts b/packages/website/ts/local_storage/state_storage.ts new file mode 100644 index 000000000..517784b5b --- /dev/null +++ b/packages/website/ts/local_storage/state_storage.ts @@ -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() }; + }, +}; |