A switch case for actions.
Exposes a single match()
function that —
- Accepts two arguments —
default
andspec
. -
default
is a function that accepts theaction.value
and can return anything. -
spec
is an object where key isaction.type
and value is a function.
import {action} from 'action-types'
import {match} from 'match-action'
const fn = match(i => i, {
inc: i => i + 1,
dec: i => i - 1
})
fn(action('inc', 10)) // returns 11