import {createStore, applyMiddleware} from 'redux';
import createSagaMiddleware from 'redux-saga';
import appStoreReducer from 'reducers';
import {loadLocationsSaga} from 'actions';

let store = null;

export function getStore() {
    if (!store) {
        throw new Error('Store doesn\'t create yet. Call createAppStore() first');
    }
    return store;
}

export function createAppStore() {
    const sagaMiddleware = createSagaMiddleware();
    store = createStore(appStoreReducer, applyMiddleware(sagaMiddleware));
    sagaMiddleware.run(loadLocationsSaga);
    return store;
}

import {createStore, applyMiddleware, compose} from 'redux';
import createSagaMiddleware from 'redux-saga';
import appStoreReducer from 'reducers';
import {loadLocationsSaga} from 'actions';

let store = null;

export function getStore() {
    if (!store) {
        throw new Error('Store doesn\'t create yet. Call createAppStore() first');
    }
    return store;
}

export function createAppStore() {
    const sagaMiddleware = createSagaMiddleware();
    const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
    store = createStore(
        appStoreReducer,
        composeEnhancers(
            applyMiddleware(sagaMiddleware)
        )
    );
    sagaMiddleware.run(loadLocationsSaga);
    return store;
}

Add middleware to work with Redux chrome extension
Add middleware to work with Redux chrome extension

Extension page:
https://github.com/zalmoxisus/redux-devtools-extension
