https://github.com/threepointone/react-redux-optimist
react bindings for redux-optimist
https://github.com/threepointone/react-redux-optimist
Last synced: 2 months ago
JSON representation
react bindings for redux-optimist
- Host: GitHub
- URL: https://github.com/threepointone/react-redux-optimist
- Owner: threepointone
- Created: 2016-02-13T21:14:45.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-15T19:24:30.000Z (over 9 years ago)
- Last Synced: 2025-01-25T08:11:33.495Z (4 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
react-redux-optimist
---react bindings for [redux-optimist](https://github.com/ForbesLindesay/redux-optimist)

```jsx
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 `` tag high up in your react tree
- read the `optimist` helper function off `context`
- dispatch!- from the work on [redux-react-local](https://github.com/threepointone/redux-react-local)