source: trip-planner-front/node_modules/rxjs/_esm2015/internal/Notification.js@ 571e0df

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

initial commit

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