Subtheme of barrio
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1 lines
6.8 KiB

{"version":3,"file":"Notification.js","sourceRoot":"","sources":["../src/Notification.ts"],"names":[],"mappings":";AACA,2BAA2B,cAAc,CAAC,CAAA;AAE1C;;;;;;;;;;;;;GAaG;AACH;IAGE,sBAAmB,IAAY,EAAS,KAAS,EAAS,KAAW;QAAlD,SAAI,GAAJ,IAAI,CAAQ;QAAS,UAAK,GAAL,KAAK,CAAI;QAAS,UAAK,GAAL,KAAK,CAAM;QACnE,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,GAAG,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,8BAAO,GAAP,UAAQ,QAA4B;QAClC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAClB,KAAK,GAAG;gBACN,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpD,KAAK,GAAG;gBACN,MAAM,CAAC,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACtD,KAAK,GAAG;gBACN,MAAM,CAAC,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACpD,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACH,yBAAE,GAAF,UAAG,IAAwB,EAAE,KAA0B,EAAE,QAAqB;QAC5E,IAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YACb,KAAK,GAAG;gBACN,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAClC,KAAK,GAAG;gBACN,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAA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AM,CAAC,IAAI,YAAY,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACI,2BAAc,GAArB;QACE,MAAM,CAAC,YAAY,CAAC,oBAAoB,CAAC;IAC3C,CAAC;IAlCc,iCAAoB,GAAsB,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;IAChE,uCAA0B,GAAsB,IAAI,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAkClG,mBAAC;AAAD,CAAC,AAjHD,IAiHC;AAjHY,oBAAY,eAiHxB,CAAA","sourcesContent":["import { PartialObserver } from './Observer';\nimport { Observable } from './Observable';\n\n/**\n * Represents a push-based event or value that an {@link Observable} can emit.\n * This class is particularly useful for operators that manage notifications,\n * like {@link materialize}, {@link dematerialize}, {@link observeOn}, and\n * others. Besides wrapping the actual delivered value, it also annotates it\n * with metadata of, for instance, what type of push message it is (`next`,\n * `error`, or `complete`).\n *\n * @see {@link materialize}\n * @see {@link dematerialize}\n * @see {@link observeOn}\n *\n * @class Notification<T>\n */\nexport class Notification<T> {\n hasValue: boolean;\n\n constructor(public kind: string, public value?: T, public error?: any) {\n this.hasValue = kind === 'N';\n }\n\n /**\n * Delivers to the given `observer` the value wrapped by this Notification.\n * @param {Observer} observer\n * @return\n */\n observe(observer: PartialObserver<T>): any {\n switch (this.kind) {\n case 'N':\n return observer.next && observer.next(this.value);\n case 'E':\n return observer.error && observer.error(this.error);\n case 'C':\n return observer.complete && observer.complete();\n }\n }\n\n /**\n * Given some {@link Observer} callbacks, deliver the value represented by the\n * current Notification to the correctly corresponding callback.\n * @param {function(value: T): void} next An Observer `next` callback.\n * @param {function(err: any): void} [error] An Observer `error` callback.\n * @param {function(): void} [complete] An Observer `complete` callback.\n * @return {any}\n */\n do(next: (value: T) => void, error?: (err: any) => void, complete?: () => void): any {\n const kind = this.kind;\n switch (kind) {\n case 'N':\n return next && next(this.value);\n case 'E':\n return error && error(this.error);\n case 'C':\n return complete && complete();\n }\n }\n\n /**\n * Takes an Observer or its individual callback functions, and calls `observe`\n * or `do` methods accordingly.\n * @param {Observer|function(value: T): void} nextOrObserver An Observer or\n * the `next` callback.\n * @param {function(err: any): void} [error] An Observer `error` callback.\n * @param {function(): void} [complete] An Observer `complete` callback.\n * @return {any}\n */\n accept(nextOrObserver: PartialObserver<T> | ((value: T) => void), error?: (err: any) => void, complete?: () => void) {\n if (nextOrObserver && typeof (<PartialObserver<T>>nextOrObserver).next === 'function') {\n return this.observe(<PartialObserver<T>>nextOrObserver);\n } else {\n return this.do(<(value: T) => void>nextOrObserver, error, complete);\n }\n }\n\n /**\n * Returns a simple Observable that just delivers the notification represented\n * by this Notification instance.\n * @return {any}\n */\n toObservable(): Observable<T> {\n const kind = this.kind;\n switch (kind) {\n case 'N':\n return Observable.of(this.value);\n case 'E':\n return Observable.throw(this.error);\n case 'C':\n return Observable.empty<T>();\n }\n throw new Error('unexpected notification kind value');\n }\n\n private static completeNotification: Notification<any> = new Notification('C');\n private static undefinedValueNotification: Notification<any> = new Notification('N', undefined);\n\n /**\n * A shortcut to create a Notification instance of the type `next` from a\n * given value.\n * @param {T} value The `next` value.\n * @return {Notification<T>} The \"next\" Notification representing the\n * argument.\n */\n static createNext<T>(value: T): Notification<T> {\n if (typeof value !== 'undefined') {\n return new Notification('N', value);\n }\n return Notification.undefinedValueNotification;\n }\n\n /**\n * A shortcut to create a Notification instance of the type `error` from a\n * given error.\n * @param {any} [err] The `error` error.\n * @return {Notification<T>} The \"error\" Notification representing the\n * argument.\n */\n static createError<T>(err?: any): Notification<T> {\n return new Notification('E', undefined, err);\n }\n\n /**\n * A shortcut to create a Notification instance of the type `complete`.\n * @return {Notification<any>} The valueless \"complete\" Notification.\n */\n static createComplete(): Notification<any> {\n return Notification.completeNotification;\n }\n}\n"]}