An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

        

react-redux-optimist
---

react bindings for [redux-optimist](https://github.com/ForbesLindesay/redux-optimist)

![halffull](https://i.imgur.com/hAprwfP.jpg)

```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)