Code coverage report for src/operator/dematerialize.ts

Statements: 100% (15 / 15)      Branches: 100% (0 / 0)      Functions: 100% (6 / 6)      Lines: 100% (13 / 13)      Ignored: none     

All files » src/operator/ » dematerialize.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    1             1 12     2 1 12   1   1 1 12     1 19   1  
import {Operator} from '../Operator';
import {Observable} from '../Observable';
import {Subscriber} from '../Subscriber';
import {Notification} from '../Notification';
 
/**
 * Returns an Observable that transforms Notification objects into the items or notifications they represent.
 * @returns {Observable} an Observable that emits items and notifications embedded in Notification objects emitted by the source Observable.
 */
export function dematerialize<T>(): Observable<any> {
  return this.lift(new DeMaterializeOperator());
}
 
class DeMaterializeOperator<T extends Notification<any>, R> implements Operator<T, R> {
  call(subscriber: Subscriber<any>) {
    return new DeMaterializeSubscriber(subscriber);
  }
}
 
class DeMaterializeSubscriber<T extends Notification<any>> extends Subscriber<T> {
  constructor(destination: Subscriber<any>) {
    super(destination);
  }
 
  protected _next(value: T) {
    value.observe(this.destination);
  }
}