Platform: @ngrx/effects fires same request twice

Created on 19 Jul 2018  路  3Comments  路  Source: ngrx/platform

Minimal reproduction of the bug/regression with instructions:

There is a similar issue closed with indication 'works as designed', but it appears not to work that way at least on my end.

Here's a reproduction of the issue:
https://stackblitz.com/edit/angular-gfh6pn

One remark regarding throttle operator in the effects - if commented out, effect fires POST request, cancels it immediately, then fires pre-flight and POST again.
With throttle, there are no cancelled requests, but both pre-flight and POST are duplicated.

In the similar issue closed there were a couple of suggestions to tackle this behavior:

  • use .share() - does not help the issue in my case
  • avoid importing EffectsModule.forRoot(), but provide effects class in providers array - does not work at all, effects are not evaluated
  • avoid double subscription, which I seem not to have in my case

Expected behavior:

pre-flight request followed by an actual request each time action is triggered, no duplicated requests

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):

  • NgRx related dependencies:
    "@ngrx/core": "^1.2.0",
    "@ngrx/effects": "^6.0.1",
    "@ngrx/store": "^6.0.1",
    "@ngrx/store-devtools": "^6.0.1",
    "@ngrx/store-log-monitor": "^3.0.2"
  • Angular 6.0.9
  • Node 10.0.0
  • Chrome Version 67.0.3396.99 (Official Build) (64-bit)
  • macOs High Sierra 10.13.6

Other information:

None

I would be willing to submit a PR to fix this issue

[ ] Yes (Assistance is provided if you need help submitting a pull request)
[x] No

Most helpful comment

If you want to complete your request before another request can be made you should use the RxJS exhaustMap operator.

If you have any questions I'll be glad to help you in our gitter channel.

All 3 comments

If you want to complete your request before another request can be made you should use the RxJS exhaustMap operator.

If you have any questions I'll be glad to help you in our gitter channel.

@timdeschryver thank you so much

This also solve my issue as well thanks @timdeschryver

Was this page helpful?
0 / 5 - 0 ratings