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

delayWhen doesn't emit when the duration selector is empty() #3663

Closed
Airblader opened this issue May 7, 2018 · 6 comments · Fixed by #3664 or severest/retrobot#221
Closed

delayWhen doesn't emit when the duration selector is empty() #3663

Airblader opened this issue May 7, 2018 · 6 comments · Fixed by #3664 or severest/retrobot#221

Comments

@Airblader
Copy link
Contributor

Airblader commented May 7, 2018

RxJS version: 6.1.0

Code to reproduce:

of(42).pipe(delayWhen(() => empty()))
  .subscribe(console.log);

Expected behavior:

This should log 42 immediately, as empty completes immediately which according to the docs should suffice even if the duration selector doesn't emit:

The source value is emitted on the output Observable only when the duration Observable emits a value or completes.

Actual behavior:

The observable completes without emission.

@Airblader
Copy link
Contributor Author

Airblader commented May 7, 2018

of(42).pipe(delayWhen(() => empty().delay(0)))
  .subscribe(console.log);

does work as intended, so this seems to be an issue with the synchronicity.

Airblader added a commit to Airblader/rxjs that referenced this issue May 7, 2018
…hronously

This fixes an issue where delayWhen would not re-emit a source emission if the duration selector
completed synchronously.

ReactiveX#3663
@cartant
Copy link
Collaborator

cartant commented May 7, 2018

Looking at the existing implementation of delayWhen I found another problem. See #3665 if you are interested in fixing it whilst you are working with that particular operator's implementation. The fix should go into its own PR, of course.

@Airblader
Copy link
Contributor Author

Yeah, I thought about this when first looking at it as well and then just forgot about it. I think my first PR attempt is no good. We'll need a better solution.

@Airblader
Copy link
Contributor Author

OK, subscribeToResult memorizes the outerValue, so I think we can use that and be good. Updating the PR.

Airblader added a commit to Airblader/rxjs that referenced this issue May 7, 2018
…hronously

This fixes an issue where delayWhen would not re-emit a source emission if the duration selector
completed synchronously.

fixes ReactiveX#3663
Airblader added a commit to Airblader/rxjs that referenced this issue May 7, 2018
…hronously

This fixes an issue where delayWhen would not re-emit a source emission if the duration selector
completed synchronously.

fixes ReactiveX#3663
@benlesh
Copy link
Member

benlesh commented May 9, 2018

The OP here isn't valid. of(42).pipe(() => empty()) should return empty, effectively... so there would be no emission.

@benlesh benlesh closed this as completed May 9, 2018
@Airblader
Copy link
Contributor Author

@benlesh Sorry, I messed up my OP when editing it. It's missing the delayWhen.

The correct example was

of(42).pipe(delayWhen(() => empty()))
  .subscribe(console.log);

Airblader added a commit to Airblader/rxjs that referenced this issue May 21, 2018
…hronously

This fixes an issue where delayWhen would not re-emit a source emission if the duration selector
completed synchronously.

fixes ReactiveX#3663
benlesh pushed a commit that referenced this issue May 31, 2018
…hronously (#3664)

* fix(delayWhen): Emit source value if duration selector completes synchronously

This fixes an issue where delayWhen would not re-emit a source emission if the duration selector
completed synchronously.

fixes #3663

* docs(delayWhen): Deprecate completion of notifier triggering source emission

This deprecates the behavior that the completion of the notifier observable will cause the source
emission to be emitted on the output observable.
@lock lock bot locked as resolved and limited conversation to collaborators Jun 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants