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. * * @see {@link Notification} * * @return {Observable} an Observable that emits items and notifications embedded in Notification objects emitted by the source Observable. * @method dematerialize * @owner Observable */ export function dematerialize(): Observable { return this.lift(new DeMaterializeOperator()); } export interface DematerializeSignature { (): Observable; } class DeMaterializeOperator, R> implements Operator { call(subscriber: Subscriber, source: any): any { return source._subscribe(new DeMaterializeSubscriber(subscriber)); } } /** * We need this JSDoc comment for affecting ESDoc. * @ignore * @extends {Ignored} */ class DeMaterializeSubscriber> extends Subscriber { constructor(destination: Subscriber) { super(destination); } protected _next(value: T) { value.observe(this.destination); } }