react-redux-optimist
v1.0.3
Published
react bindings for redux-optimist
Downloads
13
Readme
react-redux-optimist
react bindings for redux-optimist
let o = this.context.optimist('add_todo');
// optimistically update with an action
dispatch(o.begin({payload, ...}))
// -> {type: 'add_to', payload, optimist: {}, ...}
// after some async stuff, dispatch a commit
dispatch(o.commit({payload, ...}))
// -> {type: 'add_to:commit', payload, optimist: {}, ...}
// or if you you want to revert the optimistic update
dispatch(o.revert({payload, error, ...}))
// -> {type: 'add_to:revert', payload, error, optimist: {}, ...}
// you could override the generated action types, of course.
getting started
integrate redux-optimist into your redux stack
put the
<Optimist>
tag high up in your react treeread the
optimist
helper function offcontext
dispatch!
from the work on redux-react-local