Usage

createAction(type, payloadCreator = Identity, ?metaCreator)

import { createAction } from 'redux-action'
`</pre>

Wraps an action creator so that its return value is the payload of a Flux Standard Action. If no payload creator is passed, or if it's not a function, the identity function is used.

### Example

<pre>`let increment = createAction('INCREMENT', amount =&gt; amount);
// same as
increment = createAction('INCREMENT');

expect(increment(42)).to.deep.equal({
  type:'INCREMENT',
  payload: 42,
});
`</pre>

If the payload is an instance of an Error Object, redux-actions will automatically set `action.error` to true.

### Example

<pre>`const increment = createAction('INCREMENT');

const error = new TypeError('not a number');
expect(increment(error)).to.deep.equal({
  type: 'INCREMENT',
  payload: error,
  error: true,
})
`</pre>

`createAction` also return its `type` when used as type in `handleAction` or `handleActions`

### Example

<pre>`const increment = createAction('INCREMENT')

// as parameter in handleAction:

handleAction(increment, {
  next(state, action){...},
  throw(state, action) {...},
});

const reducer = handleActions({
  [increment]: (state, action) =&gt; ({
    counter: state.counter + action.payload
  })
})
`</pre>

### createActions(?actionsMap, ?...identityActions)

<pre>`import { createActions } from from 'redux-actions'
`</pre>

Returns an object mapping action types to action creator. The keys of this object are camel-cased from the keys in `actionsMap` and the string literals of `identityActions` the values are the action creators.

### combineActions(...actionTypes)

Combine any number of action types or action creators, `actionTypes` is a list of positional arguments which can be action type strings, symbols, or action creators.

This allows you to reduce multiple distinct actions with the same reducers.

<pre>`const { increment, decrement } = createActions({
  INCREMENT: amount =&gt; ({amount}),
  DECREMENT: amount =&gt; ({amount: -amount}),
})

const reducer = handleAction(combineActions(increment, decrement), {
  next: (state, { payload: { amount }}) =&gt; ({ ...state, counter: state.counter + amount}),
  throw: state =&gt; ({ ...state, counter: 0}),
}, { counter: 10 })

expect(reducer(undefined, increment(1)).to.deep.equal({ counter: 11 }))
expect(reducer(undefined, decrement(1)).to.deep.equal({ counter: 9 }))
expect(reducer(undefined, increment(new Error)).to.deep.equal({ counter: 0 }))
expect(reducer(undefined, decrement(new Error)).to.deep.equal({ counter: 0 }))