aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/redux/store.ts
blob: 203f068a1909c33b74ef1d8f1ead9c43ac0a8367 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import * as _ from 'lodash';
import { createStore, Store as ReduxStore } from 'redux';
import { devToolsEnhancer } from 'redux-devtools-extension/developmentOnly';
import { stateStorage } from 'ts/local_storage/state_storage';
import { reducer, State } from 'ts/redux/reducer';

const ONE_SECOND = 1000;

export const store: ReduxStore<State> = createStore(
    reducer,
    stateStorage.getPersistedDefaultState(),
    devToolsEnhancer({ name: '0x Website Redux Store' }),
);
store.subscribe(
    _.throttle(() => {
        // Persisted state
        stateStorage.saveState({
            hasPortalOnboardingBeenSeen: store.getState().hasPortalOnboardingBeenSeen,
        });
    }, ONE_SECOND),
);