mori-reducer

1.0.6 • Public • Published

Installation

  • Just run npm install mori-reducer or 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
  • cd into its directory
  • run npm install
  • run npm test to test this package

Contributors

Uses

Package Sidebar

Install

npm i mori-reducer

Weekly Downloads

1

Version

1.0.6

License

ISC

Last publish

Collaborators

  • frankvanvuuren