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

[QUESTION] 3-phase async dispatch #100

Closed
johanneslumpe opened this issue Jun 15, 2015 · 8 comments
Closed

[QUESTION] 3-phase async dispatch #100

johanneslumpe opened this issue Jun 15, 2015 · 8 comments

Comments

@johanneslumpe
Copy link
Contributor

In Flummox we had the ability to auto-dispatch begin, success and failure actions. I assume in redux we can do this by creating a custom middleware, which could inspect the type of the action which returned the promise and then dispatched a success or failure action depending on whether the promise gets resolved or rejected. Does this sound correct to you? If so, would it make sense to include something like this as stock middleware in redux?

@gaearon
Copy link
Contributor

gaearon commented Jun 15, 2015

I was thinking of something like this:

#99 (comment)

As discussed in Slack, it might be better to create an organization and have a few “blessed” middlewares coming from it, with separate versioning from Redux.

@gaearon
Copy link
Contributor

gaearon commented Jun 15, 2015

Oh wait, I actually meant this: #99 (comment)

(Which is why it should have separate versioning lol)

@johanneslumpe
Copy link
Contributor Author

Yeah I agree. But something like you mentioned on the other issue seems like it would be a good candidate for one such middleware. Maybe not in the exact way, but similar (I'm still trying to figure out how to use less constants ;) )

@goatslacker
Copy link

Can we also have an auto-dispatch after action which works kinda like finally?

@johanneslumpe
Copy link
Contributor Author

so a 4-phase dispatch - begin, success/failure, end. @goatslacker what would you use after or end for? to make sure that certain stores only get notified after other stores processed the success or failure dispatches?

@acdlite
Copy link
Collaborator

acdlite commented Jun 15, 2015

@johanneslumpe There's only one store.

@acdlite
Copy link
Collaborator

acdlite commented Jun 15, 2015

See @gaearon's comment about composing stores in lieu of waitFor() https://gist.github.com/gaearon/d77ca812015c0356654f

@gaearon
Copy link
Contributor

gaearon commented Jun 16, 2015

I'm closing as not a real issue, but I'd be happy to see some middleware outside the core!

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

4 participants