/*
 Rookeries client - redux application store

 @copyright (c) Copyright 2013-2016 Dorian Pula
 @license AGPL v3
 @author Dorian Pula [dorian.pula@amber-penguin-software.ca]
 */

import {createStore, applyMiddleware, compose} from "redux";
import createLogger from "redux-logger";
import thunkMiddleware from "redux-thunk";

import {reducer} from './reducers';


const loggingMiddleware = createLogger();

// TODO: Add separate stores for dev and production.
// TODO: See https://github.com/chentsulin/electron-react-boilerplate/tree/master/app/store

const appStore = createStore(
    reducer,
    compose(
        applyMiddleware(loggingMiddleware, thunkMiddleware),
        // (typeof(window) !== 'undefined' && window.devToolsExtension) ? window.devToolsExtension() : (f) => {return f;}
        typeof window === 'object' && typeof window.devToolsExtension !== 'undefined' ? window.devToolsExtension() : (f) => {return f;}
    )
);

export { appStore };
