threepointone / redux-react-local

local component state via redux
369 stars 21 forks source link

optimistic updates #5

Closed threepointone closed 8 years ago

threepointone commented 8 years ago

much like redux-optimist, but hides some of the boilerplate


let o = $opt('add_todo');

dispatch(o.begin({ text }));  
// type: 'add_todo', payload: {text}

// ...something asynchronous...

dispatch(o.commit({ text, res: asyncData }));
// type: 'add_todo:done', payload: {text, res}

// ... or if an error occurred... 
dispatch(o.revert({ text }, error));  
// type: 'add_todo:fail', payload: {text, res}, error

will also be available inside sagas as $opt

will commit soon.

threepointone commented 8 years ago

commited in https://github.com/threepointone/redux-react-local/commit/8fc2dd459b0fd43a3dd577bb46a57930169cd21d, will update readme and then close this.

threepointone commented 8 years ago

This will be pulled into its own module soon.

threepointone commented 8 years ago

pulled out as react-redux-optimist