"use strict"; var Observable_1 = require('./Observable'); var Notification = (function () { function Notification(kind, value, exception) { this.kind = kind; this.value = value; this.exception = exception; this.hasValue = kind === 'N'; } Notification.prototype.observe = function (observer) { switch (this.kind) { case 'N': return observer.next && observer.next(this.value); case 'E': return observer.error && observer.error(this.exception); case 'C': return observer.complete && observer.complete(); } }; Notification.prototype.do = function (next, error, complete) { var kind = this.kind; switch (kind) { case 'N': return next && next(this.value); case 'E': return error && error(this.exception); case 'C': return complete && complete(); } }; Notification.prototype.accept = function (nextOrObserver, error, complete) { if (nextOrObserver && typeof nextOrObserver.next === 'function') { return this.observe(nextOrObserver); } else { return this.do(nextOrObserver, error, complete); } }; Notification.prototype.toObservable = function () { var kind = this.kind; switch (kind) { case 'N': return Observable_1.Observable.of(this.value); case 'E': return Observable_1.Observable.throw(this.exception); case 'C': return Observable_1.Observable.empty(); } }; Notification.createNext = function (value) { if (typeof value !== 'undefined') { return new Notification('N', value); } return this.undefinedValueNotification; }; Notification.createError = function (err) { return new Notification('E', undefined, err); }; Notification.createComplete = function () { return this.completeNotification; }; Notification.completeNotification = new Notification('C'); Notification.undefinedValueNotification = new Notification('N', undefined); return Notification; }()); exports.Notification = Notification; //# sourceMappingURL=Notification.js.map