-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from code-mancers/Define-middleware-for-prod-…
…builds Initialise thunk and alias middleware for prod builds
- Loading branch information
Showing
1 changed file
with
19 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |