A helper for reduce React Redux template code.
This project is power by Ramda.js
How to use
-
install ramda-redux
npm install ramda-redux
-
using ramda-redux for reduce template code.
How to test
npm run test
Generate API doc
npm run doc
API doc
Functions
- Action(type, payload) ⇒
Action
The Action constructor
- Pattern(type, handler) ⇒
Pattern
Pattern constructor for arguments of Matcher constructor
- Matcher(...matcherList) ⇒
Matcher
Matcher constructor
- Reducer(initState, matcher) ⇒
Reducer
Reducer constructor,return a some implement of React redux native reducer
Action(type, payload) ⇒ Action
The Action constructor
Kind: global function
Param | Type |
---|
type | string |
payload | any |
Example
const incNumberAction=Action('incNumber')
const addNumber100Action=Action('addNumber',100)
store.dispatch(incNumberAction)
store.dispatch(addNumber100Action)
Pattern(type, handler) ⇒ Pattern
Pattern constructor for arguments of Matcher constructor
Kind: global function
Param | Type |
---|
type | string |
handler | function |
Example
const incNumberPattern =Pattern(
'incNumber',
(state, payload) => R.over(
R.lensProp('number'),
R.inc,
state
)
)
const matcher=Matcher(incNumberPattern)
Matcher(...matcherList) ⇒ Matcher
Matcher constructor
Kind: global function
Param | Type |
---|
...matcherList | function |
Example
const incNumberAction=Action('incNumber')
const incNumberPattern =Pattern(
'incNumber',
(state, payload) => R.over(
R.lensProp('number'),
R.inc,
state
)
)
const matcher=Matcher(incNumberPattern)
Reducer(initState, matcher) ⇒ Reducer
Reducer constructor,return a some implement of React redux native reducer
Kind: global function
Param | Type | Description |
---|
initState | any | (object commonly) |
matcher | Matcher | |
Example
const incNumberAction=Action('incNumber')
const incNumberPattern =Pattern(
'incNumber',
R.over(
R.lensProp('number'),
R.inc
)
)
const matcher=Matcher(incNumberPattern)
const reducer=Reducer(
{number:0},
matcher
)
const store = createStore(reducer)
store.dispatch(incNumberAction)