2.0.0 • Published 5 years ago

redux-cond v2.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

redux-cond

Build Status npm

Redux reducer with cond function

Installation

// or yarn add
npm i --save redux-cond

Use

redux-cond inspired by clojure cond

Easy-to-use :smiley:

Return cond function in your reducer

// const cond = require('redux-cond')
import cond from 'redux-cond'

function reducer(state, action) {
  return cond(
    type1, f1,
    type2, f2,
    ...
  )(state, action)
}

e.g.

import cond from 'redux-cond'

const initialState = {
  count: 0
}

cond(
  'INCREMENT', state => Object.assign(state, { count: state.count + 1 }),
  'DECREMENT', state => Object.assign(state, { count: state.count - 1 })
)(initialState, { type: 'INCREMENT' }) // => { count: 1 }

f (f1, f2, ...) is a function which receive two arguments, state and action.

const f = (state, action) => { return newState }

License

MIT © g1eny0ung

2.0.0

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.1

6 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago