Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/schne324/dispatch-pass-through
Tiny utility for passing arguments through in a react-redux mapDispatchToProps call
https://github.com/schne324/dispatch-pass-through
Last synced: about 2 months ago
JSON representation
Tiny utility for passing arguments through in a react-redux mapDispatchToProps call
- Host: GitHub
- URL: https://github.com/schne324/dispatch-pass-through
- Owner: schne324
- License: mit
- Created: 2018-07-16T21:25:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-16T23:30:59.000Z (over 6 years ago)
- Last Synced: 2024-04-24T10:24:48.001Z (9 months ago)
- Language: JavaScript
- Size: 165 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![CircleCI](https://circleci.com/gh/schne324/dispatch-pass-through.svg?style=svg)](https://circleci.com/gh/schne324/dispatch-pass-through)
[![Coverage Status](https://coveralls.io/repos/github/schne324/dispatch-pass-through/badge.svg?branch=master)](https://coveralls.io/github/schne324/dispatch-pass-through?branch=master)# Dispatch pass-through
> 1 line utility mostly useful for react-redux. Specifically for `mapDispatchToProps`, which passes all arguments passed to a dispatch-wrapped action prop through to the action itself.
## Why?
I got sick of writing almost identical `mapDispatchToProps` statements in which I would just pass all arguments through to the action.
### Before (_without_ `dispatchPassThrough`)
```js
const mapDispatchToProps = dispatch => ({
setStuff: (foo, bar) => dispatch(actions.setStuff(foo, bar)),
updateThings: (a, b, c) => dispatch(actions.updateThings(a, b, c))
});
```### After (_with_ `dispatchPassThrough`)
```js
import passThrough from 'dispatch-pass-through';const mapDispatchToProps = dispatch => ({
setStuff: passThrough(dispatch, actions.setStuff),
updateThings: passThrough(dispatch, actions.updateThings)
});
```**_NOTE: THIS UTILITY MIGHT SEEM OUTRAGEOUSLY MINOR / SILLY...BECAUSE IT IS_**
## Installation
```sh
$ yarn add dispatch-pass-through
```or
```sh
$ npm install dispatch-pass-through --save
```