import { createStore, compose, applyMiddleware } from 'redux';
import createSagaMiddleware from 'redux-saga';
import * as immutableTransform from 'redux-persist-transform-immutable';
import { autoRehydrate, persistStore } from 'redux-persist';
import * as localForage from 'localforage';

import { rootReducer } from './reducers';
import rootSaga from './sagas';

// tslint:disable:no-any
// tslint:disable:no-string-literal
const devtools: any = window['__REDUX_DEVTOOLS_EXTENSION__']
  ? window['__REDUX_DEVTOOLS_EXTENSION__']()
  : (f: any) => f;

const sagaMiddleware = createSagaMiddleware();

const store = createStore<any>(
  rootReducer,
  compose(applyMiddleware(sagaMiddleware), autoRehydrate(), devtools)
);

sagaMiddleware.run(rootSaga);

persistStore(store, {
  whitelist: [
    'hitBlocklist',
    'requesterBlocklist',
    'searchFormActive',
    'tab',
    'queue',
    'sortingOption',
    'searchOptions',
    'topticonSettings'
  ],
  storage: localForage,
  transforms: [
    immutableTransform({
      whitelist: [ 'hitBlocklist', 'requesterBlocklist', 'queue' ]
    })
  ]
});

export default store;

import { createStore, compose, applyMiddleware } from 'redux';
import createSagaMiddleware from 'redux-saga';
import * as immutableTransform from 'redux-persist-transform-immutable';
import { autoRehydrate, persistStore } from 'redux-persist';
import * as localForage from 'localforage';

import { rootReducer } from './reducers';
import rootSaga from './sagas';

// tslint:disable:no-any
// tslint:disable:no-string-literal
const devtools: any = window['__REDUX_DEVTOOLS_EXTENSION__']
  ? window['__REDUX_DEVTOOLS_EXTENSION__']()
  : (f: any) => f;

const sagaMiddleware = createSagaMiddleware();

const store = createStore<any>(
  rootReducer,
  compose(applyMiddleware(sagaMiddleware), autoRehydrate(), devtools)
);

sagaMiddleware.run(rootSaga);

persistStore(store, {
  whitelist: [
    'hitBlocklist',
    'requesterBlocklist',
    'searchFormActive',
    'tab',
    'queue',
    'sortingOption',
    'searchOptions',
    'topticonSettings',
    'watchers'
  ],
  storage: localForage,
  transforms: [
    immutableTransform({
      whitelist: [ 'hitBlocklist', 'requesterBlocklist', 'queue', 'watchers' ]
    })
  ]
});

export default store;

Add watchers to persistated state.
Add watchers to persistated state.
