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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment