Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this together with redux-promise-middleware? #13

Open
ir-fuel opened this issue Aug 23, 2016 · 1 comment
Open

How to use this together with redux-promise-middleware? #13

ir-fuel opened this issue Aug 23, 2016 · 1 comment

Comments

@ir-fuel
Copy link

ir-fuel commented Aug 23, 2016

This react/redux stuff is getting pretty complicated I must say, when looking at dependencies to solve different issues ( react-router, redux-router, redux-thunk ...) and making them play together is quite a challenge, so here is another one:

I currently use redux-promise-middleware to do promise based async actions. For each action this middleware automatically generates _BEGIN, _SUCCESS, _ERROR actions that are dispatched to the reducer.

A promise based action looks like this:

export function createPromiseAction(type, promise, metaData = {}, promiseTypeSuffixes = ['BEGIN','SUCCESS','ERROR']) {
  return {
    type,
    payload: {promise},
    meta: {promiseTypeSuffixes, metaData}
  }
}

Is there a way to combine this with this library so the _ERROR ones do the revert, and the _SUCCESSones do the commit?

@deiucanta
Copy link

Hey @ir-fuel, you should check redux-optimist-promise package. It is a combination of redux-optimist and redux-promise-middleware.

https://www.npmjs.com/package/redux-optimist-promise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants