increment(n = 1)

create.increment create(actionType).increment Appropriate leaf state: number

Returns a Riduce-standard action to increment the leaf's state by n.

Parameters

Returns

action (object): a Riduce-standard action

Example

import { createStore } from 'redux'
import riduce from 'riduce'

const initialState = {
  foo: 5,
  bar: 5
}

const [reducer, actions] = riduce(initialState)
const store = createStore(reducer)

No argument provided

const incrementFoo = actions.foo.create.increment
store.dispatch(incrementFoo())
console.log(store.getState().foo) // 6

Providing an argument

const incrementBar = actions.bar.create.increment
store.dispatch(incrementBar(37))
console.log(store.getState().bar) // 42