source: trip-planner-front/node_modules/rxjs/internal/Notification.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[6a3a178]1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var empty_1 = require("./observable/empty");
4var of_1 = require("./observable/of");
5var throwError_1 = require("./observable/throwError");
6var NotificationKind;
7(function (NotificationKind) {
8 NotificationKind["NEXT"] = "N";
9 NotificationKind["ERROR"] = "E";
10 NotificationKind["COMPLETE"] = "C";
11})(NotificationKind = exports.NotificationKind || (exports.NotificationKind = {}));
12var Notification = (function () {
13 function Notification(kind, value, error) {
14 this.kind = kind;
15 this.value = value;
16 this.error = error;
17 this.hasValue = kind === 'N';
18 }
19 Notification.prototype.observe = function (observer) {
20 switch (this.kind) {
21 case 'N':
22 return observer.next && observer.next(this.value);
23 case 'E':
24 return observer.error && observer.error(this.error);
25 case 'C':
26 return observer.complete && observer.complete();
27 }
28 };
29 Notification.prototype.do = function (next, error, complete) {
30 var kind = this.kind;
31 switch (kind) {
32 case 'N':
33 return next && next(this.value);
34 case 'E':
35 return error && error(this.error);
36 case 'C':
37 return complete && complete();
38 }
39 };
40 Notification.prototype.accept = function (nextOrObserver, error, complete) {
41 if (nextOrObserver && typeof nextOrObserver.next === 'function') {
42 return this.observe(nextOrObserver);
43 }
44 else {
45 return this.do(nextOrObserver, error, complete);
46 }
47 };
48 Notification.prototype.toObservable = function () {
49 var kind = this.kind;
50 switch (kind) {
51 case 'N':
52 return of_1.of(this.value);
53 case 'E':
54 return throwError_1.throwError(this.error);
55 case 'C':
56 return empty_1.empty();
57 }
58 throw new Error('unexpected notification kind value');
59 };
60 Notification.createNext = function (value) {
61 if (typeof value !== 'undefined') {
62 return new Notification('N', value);
63 }
64 return Notification.undefinedValueNotification;
65 };
66 Notification.createError = function (err) {
67 return new Notification('E', undefined, err);
68 };
69 Notification.createComplete = function () {
70 return Notification.completeNotification;
71 };
72 Notification.completeNotification = new Notification('C');
73 Notification.undefinedValueNotification = new Notification('N', undefined);
74 return Notification;
75}());
76exports.Notification = Notification;
77//# sourceMappingURL=Notification.js.map
Note: See TracBrowser for help on using the repository browser.