match-action
v1.0.6
Published
Switch case for actions
Downloads
3
Maintainers
Readme
Match Action
A switch case for actions.
Usage
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