https://github.com/morlay/redux-actions
https://github.com/morlay/redux-actions
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/morlay/redux-actions
- Owner: morlay
- Created: 2016-08-03T05:41:11.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-12-08T08:08:56.000Z (over 9 years ago)
- Last Synced: 2025-02-08T17:17:15.469Z (over 1 year ago)
- Language: TypeScript
- Size: 34.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# redux actions
Enhancement for `redux-actions`
[](https://travis-ci.org/morlay/redux-actions)
[](https://npmjs.org/package/@morlay/redux-actions)
[](https://david-dm.org/morlay/redux-actions)
## APIs
### `createAction(type, payloadCreator = Identity, ?metaCreator)`
Usage like [`redux-actions#createAction`](https://github.com/acdlite/redux-actions#createactiontype-payloadcreator--identity-metacreator)
but will overwrite `.toString()` to the actionCreator,
`toString()` will return actionType
### `handleActions(reducerMap, ?defaultState)`
Usage like [`redux-actions#handleActions`](https://github.com/acdlite/redux-actions#handleactionsreducermap-defaultstate),
but callback of handler will be `(state, payload, meta) => ()` instead of `(state, action)`
### `buildCreateAction(actionStatusTypes): createAction`
for build multiple status action creator
## Examples
```js
import {
buildCreateAction,
createAction,
handleActions,
} from '@morlay/redux-actions';
const createMultiAction = buildCreateAction({
success: (type) => `${type}_SUCCESS`,
failed: (type) => `${type}_FAILED`,
});
const syncAction = createAction('syncAction');
const asyncAction = createMultiAction('asyncAction');
const reducer = handleActions({
[syncAction]: ({ counter }, payload) => ({
counter: payload,
}),
[asyncAction.success]: ({ counter }, payload) => ({
counter: counter + payload,
}),
});
```