Home Manual Reference Source Test Repository

es6/operator/isEmpty.js

import { Subscriber } from '../Subscriber';
/**
 * 如果源 Observable 是空的话,它返回一个发出 true 的 Observable,否则发出 false 。
 *
 * <img src="./img/isEmpty.png" width="100%">
 *
 * @return {Observable} 发出布尔值的 Observable 。
 * @method isEmpty
 * @owner Observable
 */
export function isEmpty() {
    return this.lift(new IsEmptyOperator());
}
class IsEmptyOperator {
    call(observer, source) {
        return source.subscribe(new IsEmptySubscriber(observer));
    }
}
/**
 * We need this JSDoc comment for affecting ESDoc.
 * @ignore
 * @extends {Ignored}
 */
class IsEmptySubscriber extends Subscriber {
    constructor(destination) {
        super(destination);
    }
    notifyComplete(isEmpty) {
        const destination = this.destination;
        destination.next(isEmpty);
        destination.complete();
    }
    _next(value) {
        this.notifyComplete(false);
    }
    _complete() {
        this.notifyComplete(true);
    }
}
//# sourceMappingURL=isEmpty.js.map