https://github.com/jednano/bind-action-creators
Turns an object whose values are action creators, into an object with the same keys, but with every action creator wrapped into a dispatch call so they may be invoked directly.
https://github.com/jednano/bind-action-creators
actions dispatch react redux typescript
Last synced: 3 months ago
JSON representation
Turns an object whose values are action creators, into an object with the same keys, but with every action creator wrapped into a dispatch call so they may be invoked directly.
- Host: GitHub
- URL: https://github.com/jednano/bind-action-creators
- Owner: jednano
- License: mit
- Created: 2019-12-10T17:07:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T13:34:52.000Z (over 2 years ago)
- Last Synced: 2025-03-17T04:36:46.517Z (4 months ago)
- Topics: actions, dispatch, react, redux, typescript
- Language: TypeScript
- Size: 1.95 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- Contributing: contributing.md
- License: license
Awesome Lists containing this project
README
# bind-action-creators
[](https://github.com/jedmao/bind-action-creators/actions)
[](https://codecov.io/gh/jedmao/bind-action-creators)
[](http://commitizen.github.io/cz-cli/)
[](https://github.com/xojs/xo)
[](https://github.com/prettier/prettier)
[](https://typescriptlang.org)Turns an object whose values are action creators, into an object with the same
keys, but with every action creator wrapped into a dispatch call so they may be
invoked directly.## Installation
```bash
npm install bind-action-creators
```## Usage
```ts
import bindActionCreators = require('bind-action-creators')const actionCreators = {
fetchFoo: dispatch => Promise.resolve([]),
fetchBar: dispatch => Promise.resolve([]),
}const bound = bindActionCreators(actionCreators /*, dispatch */)
```## Scripts
The following [npm scripts](https://docs.npmjs.com/misc/scripts) are made
available to you in the project root. You can run each of them with
`npm run `.### build
Runs the [TypeScript][] compiler.
### test
Runs [AVA][] in
[watch mode](https://github.com/avajs/ava/blob/master/docs/recipes/watch-mode.md),
which attempts to run only on changed files.### cover
Runs [AVA][] with
[coverage](https://github.com/avajs/ava/blob/master/docs/recipes/code-coverage.md),
dumping coverage results in `./coverage` and showing a text summary in the
console output.### commit
Runs [Commitizen](http://commitizen.github.io/cz-cli/) commit wizard, ensuring
that your commit messages conform to
[Conventional Commits](https://www.conventionalcommits.org/).### Tips
Use the [`git commit`](https://git-scm.com/docs/git-commit) command directly
with the
[`-n`, `--no-verify` option](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--n)
to bypasses the pre-commit and commit-msg hooks.[ava]: https://github.com/avajs/ava
[typescript]: http://www.typescriptlang.org/