Skip to content

Commit 16c441e

Browse files
committed
add: onli-reducer helper
1 parent 0f496e2 commit 16c441e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "onli-reducer",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "One line reducer. Simple state management without boilerplate.",
55
"main": "src/index.js",
66
"scripts": {

src/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const onliReducer = (dispatch, types) => {
2+
const newDispatch = type => action => dispatch({ type, ...action })
3+
const send = types.reduce(
4+
(acc, next) => ({ ...acc, [next]: newDispatch(next) }),
5+
{}
6+
)
7+
8+
return send
9+
}
10+
11+
export default onliReducer

0 commit comments

Comments
 (0)