1.0.6 • Published 8 years ago
mori-reducer v1.0.6
Installation
- Just run
npm install mori-reduceror anything - add
import { createReducer } from 'mori-reducer'to import this package into your code
Usage
Take a peek at this fancy snippet
import { createStore } from 'redux'
import { hashMap } from 'mori'
import { createReducer } from 'mori-reducer'
import { SOME_ACTION, SOME_OTHER_ACTION } from './action-constants'
const exampleReducer = createReducer('', hashMap(
SOME_ACTION, (state, action) => {
return 'this is a better state'
},
SOME_OTHER_ACTION, (state, action) => {
return 'this is a way better state'
}
)
const store = createStore(exampleReducer, 'initial state')
store.dispatch({type: SOME_ACTION})
// from v1.0.4 you can use a Mori.hashMap as action
store.dispatch(hashMap('type', SOME_OTHER_ACTION))
console.log(store.getState())
// 'this is a way better state'How to test
- clone this repo
cdinto its directory- run
npm install - run
npm testto test this package
Contributors
- Frank van Vuuren frank@dynngroup.com