Sha256: a09e888b36f114b0b60ef704b93b2b9ada6fc12e7fd23077a9440dff9a7933bf
Contents?: true
Size: 1016 Bytes
Versions: 49
Compression:
Stored size: 1016 Bytes
Contents
import { Operator } from '../Operator'; import { Subscriber } from '../Subscriber'; import { Observable } from '../Observable'; import { OperatorFunction } from '../interfaces'; export function isEmpty<T>(): OperatorFunction<T, boolean> { return (source: Observable<T>) => source.lift(new IsEmptyOperator()); } class IsEmptyOperator implements Operator<any, boolean> { call (observer: Subscriber<boolean>, source: any): any { return source.subscribe(new IsEmptySubscriber(observer)); } } /** * We need this JSDoc comment for affecting ESDoc. * @ignore * @extends {Ignored} */ class IsEmptySubscriber extends Subscriber<any> { constructor(destination: Subscriber<boolean>) { super(destination); } private notifyComplete(isEmpty: boolean): void { const destination = this.destination; destination.next(isEmpty); destination.complete(); } protected _next(value: boolean) { this.notifyComplete(false); } protected _complete() { this.notifyComplete(true); } }
Version data entries
49 entries across 49 versions & 4 rubygems