Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
}
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
You can’t perform that action at this time.