Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
package.dist.prod.EventProvider.js.map Maven / Gradle / Ivy
{
"version": 3,
"sources": ["../../src/EventProvider.ts"],
"sourcesContent": ["class EventProvider {\n\t_eventRegistry: Map EventListenerReturn>>;\n\n\tconstructor() {\n\t\tthis._eventRegistry = new Map();\n\t}\n\n\tattachEvent(eventName: string, fnFunction: (param: EventListenerParam) => EventListenerReturn) {\n\t\tconst eventRegistry = this._eventRegistry;\n\t\tconst eventListeners = eventRegistry.get(eventName);\n\n\t\tif (!Array.isArray(eventListeners)) {\n\t\t\teventRegistry.set(eventName, [fnFunction]);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!eventListeners.includes(fnFunction)) {\n\t\t\teventListeners.push(fnFunction);\n\t\t}\n\t}\n\n\tdetachEvent(eventName: string, fnFunction: (param: EventListenerParam) => EventListenerReturn) {\n\t\tconst eventRegistry = this._eventRegistry;\n\t\tconst eventListeners = eventRegistry.get(eventName);\n\n\t\tif (!eventListeners) {\n\t\t\treturn;\n\t\t}\n\t\tconst indexOfFnToDetach = eventListeners.indexOf(fnFunction);\n\n\t\tif (indexOfFnToDetach !== -1) {\n\t\t\teventListeners.splice(indexOfFnToDetach, 1);\n\t\t}\n\n\t\tif (eventListeners.length === 0) {\n\t\t\teventRegistry.delete(eventName);\n\t\t}\n\t}\n\n\t/**\n\t * Fires an event and returns the results of all event listeners as an array.\n\t *\n\t * @param eventName the event to fire\n\t * @param data optional data to pass to each event listener\n\t * @returns {Array} an array with the results of all event listeners\n\t */\n\tfireEvent(eventName: string, data: EventListenerParam) {\n\t\tconst eventRegistry = this._eventRegistry;\n\t\tconst eventListeners = eventRegistry.get(eventName);\n\n\t\tif (!eventListeners) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn eventListeners.map(fn => {\n\t\t\treturn fn.call(this, data);\n\t\t});\n\t}\n\n\t/**\n\t * Fires an event and returns a promise that will resolve once all listeners have resolved.\n\t *\n\t * @param eventName the event to fire\n\t * @param data optional data to pass to each event listener\n\t * @returns {Promise} a promise that will resolve when all listeners have resolved\n\t */\n\tfireEventAsync(eventName: string, data: EventListenerParam) {\n\t\treturn Promise.all(this.fireEvent(eventName, data));\n\t}\n\n\tisHandlerAttached(eventName: string, fnFunction: (param: EventListenerParam) => EventListenerReturn) {\n\t\tconst eventRegistry = this._eventRegistry;\n\t\tconst eventListeners = eventRegistry.get(eventName);\n\n\t\tif (!eventListeners) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn eventListeners.includes(fnFunction);\n\t}\n\n\thasListeners(eventName: string) {\n\t\treturn !!this._eventRegistry.get(eventName);\n\t}\n}\n\nexport default EventProvider;\n"],
"mappings": "aAAA,MAAMA,CAAuD,CAG5D,aAAc,CACb,KAAK,eAAiB,IAAI,GAC3B,CAEA,YAAYC,EAAmBC,EAAgE,CAC9F,MAAMC,EAAgB,KAAK,eACrBC,EAAiBD,EAAc,IAAIF,CAAS,EAElD,GAAI,CAAC,MAAM,QAAQG,CAAc,EAAG,CACnCD,EAAc,IAAIF,EAAW,CAACC,CAAU,CAAC,EACzC,MACD,CAEKE,EAAe,SAASF,CAAU,GACtCE,EAAe,KAAKF,CAAU,CAEhC,CAEA,YAAYD,EAAmBC,EAAgE,CAC9F,MAAMC,EAAgB,KAAK,eACrBC,EAAiBD,EAAc,IAAIF,CAAS,EAElD,GAAI,CAACG,EACJ,OAED,MAAMC,EAAoBD,EAAe,QAAQF,CAAU,EAEvDG,IAAsB,IACzBD,EAAe,OAAOC,EAAmB,CAAC,EAGvCD,EAAe,SAAW,GAC7BD,EAAc,OAAOF,CAAS,CAEhC,CASA,UAAUA,EAAmBK,EAA0B,CAEtD,MAAMF,EADgB,KAAK,eACU,IAAIH,CAAS,EAElD,OAAKG,EAIEA,EAAe,IAAIG,GAClBA,EAAG,KAAK,KAAMD,CAAI,CACzB,EALO,CAAC,CAMV,CASA,eAAeL,EAAmBK,EAA0B,CAC3D,OAAO,QAAQ,IAAI,KAAK,UAAUL,EAAWK,CAAI,CAAC,CACnD,CAEA,kBAAkBL,EAAmBC,EAAgE,CAEpG,MAAME,EADgB,KAAK,eACU,IAAIH,CAAS,EAElD,OAAKG,EAIEA,EAAe,SAASF,CAAU,EAHjC,EAIT,CAEA,aAAaD,EAAmB,CAC/B,MAAO,CAAC,CAAC,KAAK,eAAe,IAAIA,CAAS,CAC3C,CACD,CAEA,eAAeD",
"names": ["EventProvider", "eventName", "fnFunction", "eventRegistry", "eventListeners", "indexOfFnToDetach", "data", "fn"]
}