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

skipUntil(s$) doesn't complete when s$ completes #5379

Closed
akarelas opened this issue Apr 4, 2020 · 3 comments
Closed

skipUntil(s$) doesn't complete when s$ completes #5379

akarelas opened this issue Apr 4, 2020 · 3 comments

Comments

@akarelas
Copy link

akarelas commented Apr 4, 2020

Bug Report

Current Behavior
The skipUntil(x$) operator does not cause the resulting observable to complete when x$ completes before it emits a value.

Reproduction

let { interval, EMPTY } = rxjs; 
let { skipUntil, tap, delay } = rxjs.operators;

let stopper$ = EMPTY.pipe(delay(2000));

let s$ = interval(600).pipe(
    tap(v => print('tapping...')),
    skipUntil(stopper$),
);

s$.subscribe(
    null, null,
    () => print('s$ complete')
);

stopper$.subscribe(
    null, null,
    () => print('stopper$ complete')
);

function print(text) {
    let el = document.getElementById('output');
    el.innerHTML = el.innerHTML + text + '\n';
}

Expected behavior
I would expect s$ to complete as soon as stopper$ completes, and display s$ complete on the browser window immediately after stopper$ complete shows. s$ could have many subscribers, and a heavy source observable, and I think that it not competing causes a completely useless waste of resources.

Environment

  • Runtime: all
  • RxJS version: 6.5.5

Additional context/Screenshots

Output of the above script:

tapping...
tapping...
tapping...
stopper$ complete
tapping...
tapping...
tapping...
tapping...
tapping...
tapping...
tapping...
tapping...
@cartant
Copy link
Collaborator

cartant commented Apr 4, 2020

If the notifying observable completes before emitting a notification, it should not complete the observable to which the operator has been applied, so this looks to be the correct behaviour, to me.

There are other issues related to this, as the behaviour of some other operators differs and is incorrect. Changes to make operators that use notifier behave in a consistent manner are going to be made in the next major version and I've listed some in this issue: #5372

@kwonoj
Copy link
Member

kwonoj commented Apr 4, 2020

@benlesh
Copy link
Member

benlesh commented May 14, 2020

this is expected behavior.

The notifier must notify. An observable that completes without emitting a value is "empty" and will never notify. In fact, it's an Observable<never>. ;)

@benlesh benlesh closed this as completed May 14, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants