Skip to content

Commit

Permalink
Merge pull request #120 from code-mancers/Define-middleware-for-prod-…
Browse files Browse the repository at this point in the history
…builds

Initialise thunk and alias middleware for prod builds
  • Loading branch information
revathskumar authored May 15, 2018
2 parents 9304918 + 2be9e2c commit 3da9b4a
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions app/store/popup_store.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
import { createStore, applyMiddleware } from 'redux'
import { createLogger } from 'redux-logger'
import { Middleware } from 'react-redux/node_modules/redux';
import thunkMiddleware from 'redux-thunk';
import aliases from './aliases'
import { alias } from 'react-chrome-redux';

import {reducer} from './../reducers/rootReducer';
import {createStore, applyMiddleware} from "redux";
import {createLogger} from "redux-logger";
import {Middleware} from "react-redux/node_modules/redux";
import thunkMiddleware from "redux-thunk";
import aliases from "./aliases";
import {alias} from "react-chrome-redux";
import {reducer} from "./../reducers/rootReducer";
export interface PopUpInterface {
enabled: boolean;
errorMessage ?: string;
errorMessage?: string;
requests?: Array<Object>;
}
let enhancer:any;
if (process.env.NODE_ENV !== 'production') {
const logger:Middleware = createLogger({
collapsed: true,
})

enhancer = applyMiddleware(
alias(aliases),
thunkMiddleware,
logger
);
let enhancer: any;
if (process.env.NODE_ENV !== "production") {
const logger: Middleware = createLogger({
collapsed: true
});
enhancer = applyMiddleware(alias(aliases), thunkMiddleware, logger);
} else {
enhancer = applyMiddleware(alias(aliases), thunkMiddleware);
}
export default function(initalState: PopUpInterface) {
return createStore(reducer, initalState, enhancer);
}

export default function (initalState: PopUpInterface ) {
if(enhancer){
return createStore(reducer , initalState, enhancer)
}else{
return createStore(reducer , initalState)
}
}

0 comments on commit 3da9b4a

Please sign in to comment.