2 Object.defineProperty(exports, "__esModule", { value: true });
3 var empty_1 = require("./observable/empty");
4 var of_1 = require("./observable/of");
5 var throwError_1 = require("./observable/throwError");
7 (function (NotificationKind) {
8 NotificationKind["NEXT"] = "N";
9 NotificationKind["ERROR"] = "E";
10 NotificationKind["COMPLETE"] = "C";
11 })(NotificationKind = exports.NotificationKind || (exports.NotificationKind = {}));
12 var Notification = (function () {
13 function Notification(kind, value, error) {
17 this.hasValue = kind === 'N';
19 Notification.prototype.observe = function (observer) {
22 return observer.next && observer.next(this.value);
24 return observer.error && observer.error(this.error);
26 return observer.complete && observer.complete();
29 Notification.prototype.do = function (next, error, complete) {
33 return next && next(this.value);
35 return error && error(this.error);
37 return complete && complete();
40 Notification.prototype.accept = function (nextOrObserver, error, complete) {
41 if (nextOrObserver && typeof nextOrObserver.next === 'function') {
42 return this.observe(nextOrObserver);
45 return this.do(nextOrObserver, error, complete);
48 Notification.prototype.toObservable = function () {
52 return of_1.of(this.value);
54 return throwError_1.throwError(this.error);
56 return empty_1.empty();
58 throw new Error('unexpected notification kind value');
60 Notification.createNext = function (value) {
61 if (typeof value !== 'undefined') {
62 return new Notification('N', value);
64 return Notification.undefinedValueNotification;
66 Notification.createError = function (err) {
67 return new Notification('E', undefined, err);
69 Notification.createComplete = function () {
70 return Notification.completeNotification;
72 Notification.completeNotification = new Notification('C');
73 Notification.undefinedValueNotification = new Notification('N', undefined);
76 exports.Notification = Notification;
77 //# sourceMappingURL=Notification.js.map