Last active
April 23, 2018 13:17
-
-
Save kevinrutherford/9490440aadb55eff3bb825d297bdf630 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import deepFreeze from 'deep-freeze' | |
import configureStore from '../app/store/' | |
export const reduce = (actions) => { | |
const store = configureStore() | |
actions.forEach(action => store.dispatch(action)) | |
return store.getState() | |
} | |
export const reductio = (reducer, actions) => { | |
var state = reducer(undefined, {type: 'NO_SUCH_ACTION'}) | |
return apply(reducer, state, actions) | |
} | |
export const apply = (reducer, initialState, actions) => { | |
let state = initialState | |
for (var action of actions) { | |
deepFreeze(state) | |
state = reducer(state, action) | |
} | |
return state | |
} |
This file contains hidden or 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
switch (process.env.NODE_ENV) { | |
case 'production': | |
module.exports = require('./configureStore.prod') | |
break | |
case 'test': | |
module.exports = require('./configureStore.test') | |
break | |
default: | |
module.exports = require('./configureStore.dev') | |
break | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment