Code coverage report for src/operator/extended/isEmpty.ts

Statements: 100% (21 / 21)      Branches: 100% (0 / 0)      Functions: 100% (8 / 8)      Lines: 100% (19 / 19)      Ignored: none     

All files » src/operator/extended/ » isEmpty.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35  1   1 6     2 1 6   1   1   1 6     1 3   3 3     1 1     1 2   1  
import {Operator} from '../../Operator';
import {Subscriber} from '../../Subscriber';
 
export function isEmpty() {
  return this.lift(new IsEmptyOperator());
}
 
class IsEmptyOperator<T, R> implements Operator<T, R> {
  call (observer: Subscriber<boolean>): Subscriber<T> {
    return new IsEmptySubscriber<T>(observer);
  }
}
 
class IsEmptySubscriber<T> extends Subscriber<T> {
 
  constructor(destination: Subscriber<boolean>) {
    super(destination);
  }
 
  private notifyComplete(isEmpty: boolean): void {
    const destination = this.destination;
 
    destination.next(isEmpty);
    destination.complete();
  }
 
  _next(value: T) {
    this.notifyComplete(false);
  }
 
  _complete() {
    this.notifyComplete(true);
  }
}