-
Notifications
You must be signed in to change notification settings - Fork 177
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
digestMiddleware is swallowing the result of the next action #92
Comments
I have the same issue, this is supposed to work! Have you got this to work by simply |
I think the correct fix would be: const res = next(action);
$rootScope.$evalAsync(res);
return res; At least with that things like thunk chains and other middleware can work with the dispatch chain. |
Maybe I'm missing something obvious and/or this isnt the right place for this question,but why is It should eval to something other middleware would return, but without extra middleware this will be an action object. Calling Doesnt that mean this digestMiddleware is useful just to cause an async digest regardless of the param? Is this only helpful if we ever want to make custom middleware that returns an angular expression? |
It really doesn't matter what you pass into the The real issue here is that the middleware is not returning the result of the middleware chain (the return of |
@c-dante right! And I'd love your PR to be merged too. But I want to make sure the middleware shouldnt instead invoke If this was required then your proposed return wouldnt be possible. As it stands now the middleware chain will continue regardless of what As it works now, this middleware tells redux to continue and at some point in the future an angular digest is triggered - it doesnt care if redux processes the action now or later on the async queue. |
So there are a 2 problems with this:
In that example, the middleware still returns undefined and consumes the chain. Really, just triggering the digest is the important part. Getting the correct state in angular happens automatically by using the |
Any idea when a fix for this might be released? |
@TobyColeman it's been merged in and released. |
In our particular use case, we use a clientMiddleware to handle API requests which returns a promise. Based on the result of this promise, we may or may not dispatch further actions:
// snippet from clientMiddleware.js return promise(ApiClient).then( (result) => next({...rest, result, type: SUCCESS, receivedAt: Date.now()}), (error) => next({...rest, error, type: FAILURE}) ).catch((error) => { console.error('MIDDLEWARE ERROR:', error); next({...rest, error, type: FAILURE}); });
// usage this.fetchSomethingFromServer().then((success) => this.fetchSomethingElse());
digestMiddleware.js calls:
$rootScope.$evalAsync(next(action);
but doesn't return the result of next(action), so the promise is not returned and can't be chained.
The text was updated successfully, but these errors were encountered: