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

DelayQueue failed: behavior breaking change after RxJS from v6 to v7 #71

Closed
huan opened this issue May 29, 2021 · 0 comments
Closed

DelayQueue failed: behavior breaking change after RxJS from v6 to v7 #71

huan opened this issue May 29, 2021 · 0 comments

Comments

@huan
Copy link
Owner

huan commented May 29, 2021

The following code work as expected with RxJS@6:

concatMap(args => concat(
of(args), // emit first item right away
EMPTY.pipe(delay(this.period)), // delay next item
)),

It will add a delay between each item.

However, the above code does not work anymore after we upgrade to RxJS@7, it likes that all delay does not take effect anymore: all items will be emitted without any delay.

Problem: breaking changes from RxJS

After performed my google-fu, I found there's a "behavior of delay inconsistent with completions" (ReactiveX/rxjs#4249) created by @benlesh which talked about this behavior and there's also a PR named "fix(delay): emit complete notification as soon as possible" (ReactiveX/rxjs#4444) has implemented this change.

So that's the reason why our code break after upgrade to RxJS v7.

Solution

Use the following code to emit complete after the delay this.period.

concatMap(x => concat(
  of(x),
  timer(this.period).pipe(skip(1)),
)),
@huan huan closed this as completed in 14bcaba May 29, 2021
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

1 participant