{"size": 1121, "ext": "js", "max_stars_repo_path": "src/store/index.js", "max_stars_repo_name": "shaunsaker/react-native-boilerplate", "max_stars_repo_stars_event_min_datetime": "2018-05-31T16:22:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T12:33:46.000Z", "max_issues_repo_path": "src/store/index.js", "max_issues_repo_name": "shaunsaker/react-native-boilerplate", "max_issues_repo_issues_event_min_datetime": "2018-05-31T16:30:58.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-01T06:35:54.000Z", "max_forks_repo_path": "src/store/index.js", "max_forks_repo_name": "shaunsaker/react-native-boilerplate", "max_forks_repo_forks_event_min_datetime": "2018-12-23T16:46:27.000Z", "max_forks_repo_forks_event_max_datetime": "2019-04-06T03:09:54.000Z"}
{"max_stars_count": 20, "max_issues_count": 98, "max_forks_count": 5, "avg_line_length": 28.025, "max_line_length": 80, "alphanum_fraction": 0.7573595004}
import { createStore, applyMiddleware } from 'redux';
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2';
import createSagaMiddleware from 'redux-saga';
import { logger } from 'redux-logger';
import { Platform } from 'react-native';

import reducers from './reducers';
import sagas from './sagas';

// add the middlewares
const middlewares = [];

// add the saga middleware
const sagaMiddleware = createSagaMiddleware();
middlewares.push(sagaMiddleware);

// Only log store actions if dev and iOS
if (__DEV__ && Platform.OS === 'ios') {
  middlewares.push(logger);
}

// apply the middleware
const middleware = applyMiddleware(...middlewares);

const persistConfig = {
  key: 'root',
  storage,
  stateReconciler: autoMergeLevel2,
  blacklist: ['appState', 'navigation'],
};

const persistedReducer = persistReducer(persistConfig, reducers);

export const store = createStore(persistedReducer, middleware);
export const persistor = persistStore(store);

sagaMiddleware.run(sagas);
