Skip to content

Commit ad442ba

Browse files
committed
add: improve onliSend to pass send as a property
1 parent f31b5d6 commit ad442ba

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
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.1.0",
3+
"version": "0.2.0",
44
"description": "One line reducer. Simple state management without boilerplate.",
55
"main": "src/index.js",
66
"scripts": {

src/onli-send.js

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

87
return send
98
}

0 commit comments

Comments
 (0)