Skip to content

Commit 8a4162b

Browse files
Andre Medeirosstaltz
authored andcommitted
fix(skipUntil): unsubscribe source when it completes
Fix operator skipUntil to automatically unsubscribe from its source whenever it completes. This is to conform RxJS Next with RxJS 4. Resolves issue #577.
1 parent 97e2258 commit 8a4162b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/operators/skipUntil.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import Operator from '../Operator';
22
import Subscriber from '../Subscriber';
33
import Observable from '../Observable';
44

5-
export default function skipUntil(total) {
6-
return this.lift(new SkipUntilOperator(total));
5+
export default function skipUntil<T>(notifier: Observable<any>): Observable<T> {
6+
return this.lift(new SkipUntilOperator(notifier));
77
}
88

99
class SkipUntilOperator<T, R> implements Operator<T, R> {
@@ -18,8 +18,9 @@ class SkipUntilOperator<T, R> implements Operator<T, R> {
1818
class SkipUntilSubscriber<T> extends Subscriber<T> {
1919
private notificationSubscriber: NotificationSubscriber<any> = null;
2020

21-
constructor(destination: Subscriber<T>, private notifier: Observable<any>) {
22-
super(destination);
21+
constructor(public destination: Subscriber<T>,
22+
private notifier: Observable<any>) {
23+
super(null);
2324
this.notificationSubscriber = new NotificationSubscriber(this);
2425
this.add(this.notifier.subscribe(this.notificationSubscriber));
2526
}
@@ -30,6 +31,10 @@ class SkipUntilSubscriber<T> extends Subscriber<T> {
3031
}
3132
}
3233

34+
_error(err: any) {
35+
this.destination.error(err);
36+
}
37+
3338
_complete() {
3439
if (this.notificationSubscriber.hasCompleted) {
3540
this.destination.complete();

0 commit comments

Comments
 (0)