es6/operator/skipUntil.js
import { OuterSubscriber } from '../OuterSubscriber';
import { subscribeToResult } from '../util/subscribeToResult';
/**
* 返回一个 Observable,该 Observable 会跳过源 Observable 发出的值直到第二个 Observable 开始发送。
*
* <img src="./img/skipUntil.png" width="100%">
*
* @param {Observable} notifier - 第二个 Observable ,它发出后,结果 Observable 开始镜像源 Observable 的元素。
* @return {Observable<T>} Observable 跳过源 Observable 发出的值直到第二个 Observable 开始发送, 然后发出剩下的数据项。
* @method skipUntil
* @owner Observable
*/
export function skipUntil(notifier) {
return this.lift(new SkipUntilOperator(notifier));
}
class SkipUntilOperator {
constructor(notifier) {
this.notifier = notifier;
}
call(subscriber, source) {
return source.subscribe(new SkipUntilSubscriber(subscriber, this.notifier));
}
}
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
class SkipUntilSubscriber extends OuterSubscriber {
constructor(destination, notifier) {
super(destination);
this.hasValue = false;
this.isInnerStopped = false;
this.add(subscribeToResult(this, notifier));
}
_next(value) {
if (this.hasValue) {
super._next(value);
}
}
_complete() {
if (this.isInnerStopped) {
super._complete();
}
else {
this.unsubscribe();
}
}
notifyNext(outerValue, innerValue, outerIndex, innerIndex, innerSub) {
this.hasValue = true;
}
notifyComplete() {
this.isInnerStopped = true;
if (this.isStopped) {
super._complete();
}
}
}
//# sourceMappingURL=skipUntil.js.map