1 import { empty } from './observable/empty';
2 import { of } from './observable/of';
3 import { throwError } from './observable/throwError';
4 export var NotificationKind;
5 (function (NotificationKind) {
6 NotificationKind["NEXT"] = "N";
7 NotificationKind["ERROR"] = "E";
8 NotificationKind["COMPLETE"] = "C";
9 })(NotificationKind || (NotificationKind = {}));
10 export class Notification {
11 constructor(kind, value, error) {
15 this.hasValue = kind === 'N';
20 return observer.next && observer.next(this.value);
22 return observer.error && observer.error(this.error);
24 return observer.complete && observer.complete();
27 do(next, error, complete) {
28 const kind = this.kind;
31 return next && next(this.value);
33 return error && error(this.error);
35 return complete && complete();
38 accept(nextOrObserver, error, complete) {
39 if (nextOrObserver && typeof nextOrObserver.next === 'function') {
40 return this.observe(nextOrObserver);
43 return this.do(nextOrObserver, error, complete);
47 const kind = this.kind;
50 return of(this.value);
52 return throwError(this.error);
56 throw new Error('unexpected notification kind value');
58 static createNext(value) {
59 if (typeof value !== 'undefined') {
60 return new Notification('N', value);
62 return Notification.undefinedValueNotification;
64 static createError(err) {
65 return new Notification('E', undefined, err);
67 static createComplete() {
68 return Notification.completeNotification;
71 Notification.completeNotification = new Notification('C');
72 Notification.undefinedValueNotification = new Notification('N', undefined);
73 //# sourceMappingURL=Notification.js.map