Closed dagda1 closed 8 years ago
This is a usage question, and not really anything related to Redux itself. You're better off asking this on Stack Overflow.
thank you for your response. very helpful
On Sun, 13 Nov 2016 at 17:45, Mark Erikson notifications@github.com wrote:
Closed #2099 https://github.com/reactjs/redux/issues/2099.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/reactjs/redux/issues/2099#event-857062967, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHOOPLyHFk_h1evlC1CBLNW0XqhYy4hks5q90zWgaJpZM4KwrVc .
I have the following middleware that I use to call similar async calls:
I am then making the following calls in
componentWillMount
of a component:fetchTeams
for example will dispatch an action that is handled by the middleware, that looks like this:Both the success actions are dispatched and the new state is returned from the reducer. Both reducers look the same and below is the
Teams
reducer:The component then renders another component that dispatches another action:
Autocomplete then dispatches an action in its
componentWillMount
:if an error happens in the autocomplete reducer that is invoked after the SUCCESS reducers have been invoked for
fetchTeams
andfetchResults
from the original calls incomponentWillMount
of the parent component and the error will be handled in thePromise.catch
of thecallApi
method that happens in the middleware.This is because it is happening with in the same tick of the event loop. If I introduce some asynchronicity in the
Autcomplete
componentWIllMount
function then the error is not handled in the Promise catch handler of the middlewareThis is presumably why Redux loop and Redux saga. What is the best way of ensuring that the asynchronous Promise in the middleware happens within its own eventloop tick?