-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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
Docs: Added clarity re return value of store.dispatch #1103
Conversation
The reason that it is specified solely as a plain object is explained in the Notes section below. Is there anything there you would suggest to change to make it clearer? |
True! Perhaps adding a "see notes"? API references should be easy to lookup quickly - notes are easy to overlook. |
"Promise of dispatch action object" sounds very specific as if we enforce something like that. I'd just say "a Promise" there. |
Added a "see notes" so that it's more clear that this return value can change.
I feel like the focus here should be on the end value being the action object. It gives middleware creators more direction and can improve consistency within the ecosystem. |
I don't think this is necessarily true at all. Async action creators often dispatch multiple actions. I don't think it makes sense to suggest it's the action that the Promise should resolve to. |
When middleware can return anything, it makes the return from store.dispatch more complicated and less type safe. Whereas the general pattern of When multiple actions are dispatched, the middleware should be able to comfortably provide either:
I don't see the down side to encouraging this? |
I agree that a standard return value of I don't think a standard return value should be required, but I think encouraging a standard would be beneficial. I say this because I also think that if it makes sense for a middleware to return a value other than the standard, e.g., a promise object, then that is acceptable. Maybe the update to the docs should express this? |
It may also be worth noting that this is coming from discussions at pburtchaell/redux-promise-middleware#39 and este/este#633. |
I think adding |
Docs: Added clarity re return value of store.dispatch
Oh, where are my manners? Thanks Tomatau! |
@ellbee Hah thanks, was a very trivial PR :) I very like the idea of a standard with link in the docs -- just a github readme page should be enough. I don't see how any libraries could really help here, perhaps a middleware to check against the dispatch return from following middleware. |
Added some more information about the return value of store.dispatch.
It should be the dispatched action but could also be the return value of the middleware chain, such as a promise of the dispatched action