You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.8 KiB
77 lines
2.8 KiB
"use strict"; |
|
var __extends = (this && this.__extends) || function (d, b) { |
|
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; |
|
function __() { this.constructor = d; } |
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
}; |
|
var Subscriber_1 = require('../Subscriber'); |
|
/** |
|
* Converts an Observable of {@link Notification} objects into the emissions |
|
* that they represent. |
|
* |
|
* <span class="informal">Unwraps {@link Notification} objects as actual `next`, |
|
* `error` and `complete` emissions. The opposite of {@link materialize}.</span> |
|
* |
|
* <img src="./img/dematerialize.png" width="100%"> |
|
* |
|
* `dematerialize` is assumed to operate an Observable that only emits |
|
* {@link Notification} objects as `next` emissions, and does not emit any |
|
* `error`. Such Observable is the output of a `materialize` operation. Those |
|
* notifications are then unwrapped using the metadata they contain, and emitted |
|
* as `next`, `error`, and `complete` on the output Observable. |
|
* |
|
* Use this operator in conjunction with {@link materialize}. |
|
* |
|
* @example <caption>Convert an Observable of Notifications to an actual Observable</caption> |
|
* var notifA = new Rx.Notification('N', 'A'); |
|
* var notifB = new Rx.Notification('N', 'B'); |
|
* var notifE = new Rx.Notification('E', void 0, |
|
* new TypeError('x.toUpperCase is not a function') |
|
* ); |
|
* var materialized = Rx.Observable.of(notifA, notifB, notifE); |
|
* var upperCase = materialized.dematerialize(); |
|
* upperCase.subscribe(x => console.log(x), e => console.error(e)); |
|
* |
|
* // Results in: |
|
* // A |
|
* // B |
|
* // TypeError: x.toUpperCase is not a function |
|
* |
|
* @see {@link Notification} |
|
* @see {@link materialize} |
|
* |
|
* @return {Observable} An Observable that emits items and notifications |
|
* embedded in Notification objects emitted by the source Observable. |
|
* @method dematerialize |
|
* @owner Observable |
|
*/ |
|
function dematerialize() { |
|
return function dematerializeOperatorFunction(source) { |
|
return source.lift(new DeMaterializeOperator()); |
|
}; |
|
} |
|
exports.dematerialize = dematerialize; |
|
var DeMaterializeOperator = (function () { |
|
function DeMaterializeOperator() { |
|
} |
|
DeMaterializeOperator.prototype.call = function (subscriber, source) { |
|
return source.subscribe(new DeMaterializeSubscriber(subscriber)); |
|
}; |
|
return DeMaterializeOperator; |
|
}()); |
|
/** |
|
* We need this JSDoc comment for affecting ESDoc. |
|
* @ignore |
|
* @extends {Ignored} |
|
*/ |
|
var DeMaterializeSubscriber = (function (_super) { |
|
__extends(DeMaterializeSubscriber, _super); |
|
function DeMaterializeSubscriber(destination) { |
|
_super.call(this, destination); |
|
} |
|
DeMaterializeSubscriber.prototype._next = function (value) { |
|
value.observe(this.destination); |
|
}; |
|
return DeMaterializeSubscriber; |
|
}(Subscriber_1.Subscriber)); |
|
//# sourceMappingURL=dematerialize.js.map
|