# redux-cac

> Helper for create action creators

Latest version **0.1.5** (published 2018-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-cac
pnpm add redux-cac
yarn add redux-cac
bun add redux-cac
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2018-03-23 |
| First published | 2018-03-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Alex Maslakov |
| Maintainers | jmas |
| Keywords | redux, action, creators |

## Links

- npm: https://www.npmjs.com/package/redux-cac
- npm.io page: https://npm.io/package/redux-cac

## Dependencies (3)

- [rollup](https://npm.io/package/rollup.md) ^0.57.1
- [babel-preset-env](https://npm.io/package/babel-preset-env.md) ^1.6.1
- [babel-preset-stage-0](https://npm.io/package/babel-preset-stage-0.md) ^6.24.1

## Recent versions

- 0.1.5 (latest) — 2018-03-23
- 0.1.3 — 2018-03-22
- 0.1.2 — 2018-03-22
- 0.1.0 — 2018-03-22

## README

# redux-cac
Helper for create action creators. Action types constants + action creators functions now cames together.

```js
// Actions:
const actions = createActionCreators({
  increase: null,
  decrease: null,
  increaseLater: (payload, actions) => dispatch => {
    setTimeout(() => dispatch(actions.increase()), 1000)
  }
}, 'counter')

// > actions.increase()
// > { type: '@counter/increase', payload: null }
// > actions.increaseLater()
// > { type: '@counter/increase', payload: null }
// > actions.increase(1)
// > { type: '@counter/increase', payload: 1 }

// Redux store
const store = createStore((state = { count: 0 }, action) => {
  switch (action.type) {
    case actions.increase.type:
      return { ...state, count: state.count + 1 }
    case actions.decrease.type:
      return { ...state, count: state.count - 1 }
    default:
      return state
  }
}, applyMiddleware(thunk))

// Often it happens in react-redux mapDispatchToProps
const boundActions = bindActionCreators(actions, store.dispatch)

// > boundActions.increase()
// > store.getState()
// > { count: 1 }
```

> **Note!** Function `dispatch()` require [`thunk` middleware](https://github.com/gaearon/redux-thunk).

---
_Source: https://npm.io/package/redux-cac · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
