Code coverage report for src/operator/materialize.ts

Statements: 100% (24 / 24)      Branches: 100% (0 / 0)      Functions: 100% (8 / 8)      Lines: 100% (22 / 22)      Ignored: none     

All files » src/operator/ » materialize.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 36 37    1 1   1 37     2 1 37   1   1 1 37     1 50     1 3 3 3     1 17 17 17   1  
import {Operator} from '../Operator';
import {Observable} from '../Observable';
import {Subscriber} from '../Subscriber';
import {Notification} from '../Notification';
 
export function materialize<T>(): Observable<Notification<T>> {
  return this.lift(new MaterializeOperator());
}
 
class MaterializeOperator<T, R> implements Operator<T, R> {
  call(subscriber: Subscriber<T>): Subscriber<T> {
    return new MaterializeSubscriber(subscriber);
  }
}
 
class MaterializeSubscriber<T> extends Subscriber<T> {
  constructor(destination: Subscriber<T>) {
    super(destination);
  }
 
  _next(value: T) {
    this.destination.next(Notification.createNext(value));
  }
 
  _error(err: any) {
    const destination = this.destination;
    destination.next(Notification.createError(err));
    destination.complete();
  }
 
  _complete() {
    const destination = this.destination;
    destination.next(Notification.createComplete());
    destination.complete();
  }
}