Skip to content

Commit

Permalink
add: improve onliSend to pass send as a property
Browse files Browse the repository at this point in the history
  • Loading branch information
ericdouglas committed Aug 30, 2019
1 parent f31b5d6 commit ad442ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onli-reducer",
"version": "0.1.0",
"version": "0.2.0",
"description": "One line reducer. Simple state management without boilerplate.",
"main": "src/index.js",
"scripts": {
Expand Down
9 changes: 4 additions & 5 deletions src/onli-send.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
export default (dispatch, types) => {
const newDispatch = type => action => dispatch({ type, ...action })
const send = types.reduce(
(acc, next) => ({ ...acc, [next]: newDispatch(next) }),
{}
)
const send = types.reduce((acc, next) => ({ ...acc, [next]: "" }), {})
const newDispatch = type => action => dispatch({ type, send, ...action })

types.forEach(type => (send[type] = newDispatch(type)))

return send
}

0 comments on commit ad442ba

Please sign in to comment.