Skip to content

Commit 1c257db

Browse files
committedAug 19, 2018
fix(skipUntil): stop listening to a synchronous notifier after its first nexted value
1 parent 1d14277 commit 1c257db

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed
 

‎spec/operators/skipUntil-spec.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from 'chai';
22
import { hot, cold, expectObservable, expectSubscriptions } from '../helpers/marble-testing';
3-
import { Observable, of, Subject } from 'rxjs';
3+
import { concat, defer, Observable, of, Subject } from 'rxjs';
44
import { skipUntil, mergeMap } from 'rxjs/operators';
55

66
declare function asDiagram(arg: string): Function;
@@ -246,4 +246,25 @@ describe('skipUntil', () => {
246246
expectObservable(result).toBe(expected);
247247
expectSubscriptions(notifier.subscriptions).toBe(nSubs);
248248
});
249+
250+
it('should stop listening to a synchronous notifier after its first nexted value', () => {
251+
// const source = hot('-^-o---o---o---o---o---o---|');
252+
const sideEffects: number[] = [];
253+
const synchronousNotifer = concat(
254+
defer(() => {
255+
sideEffects.push(1);
256+
return of(1);
257+
}),
258+
defer(() => {
259+
sideEffects.push(2);
260+
return of(2);
261+
}),
262+
defer(() => {
263+
sideEffects.push(3);
264+
return of(3);
265+
})
266+
);
267+
of(null).pipe(skipUntil(synchronousNotifer)).subscribe(() => { /* noop */ });
268+
expect(sideEffects).to.deep.equal([1]);
269+
});
249270
});

‎src/internal/operators/skipUntil.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ class SkipUntilSubscriber<T, R> extends OuterSubscriber<T, R> {
4444

4545
constructor(destination: Subscriber<R>, notifier: ObservableInput<any>) {
4646
super(destination);
47-
this.add(this.innerSubscription = subscribeToResult(this, notifier));
47+
const innerSubscriber = new InnerSubscriber(this, undefined, undefined);
48+
this.add(innerSubscriber);
49+
this.innerSubscription = innerSubscriber;
50+
subscribeToResult(this, notifier, undefined, undefined, innerSubscriber);
4851
}
4952

5053
protected _next(value: T) {

0 commit comments

Comments
 (0)