@dropins/tools 0.36.0 → 0.37.0-alpha001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/event-bus.js +1 -1
- package/package.json +1 -1
- package/types/event-bus/src/index.d.ts +7 -0
package/event-bus.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
var o=Object.defineProperty;var f=(n,e,
|
|
3
|
+
var o=Object.defineProperty;var f=(n,e,t)=>e in n?o(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>f(n,typeof e!="symbol"?e+"":e,t);const c=Date.now().toString(36).substring(2);class a{static lastPayload(e){var t;return(t=this._lastEvent[e])==null?void 0:t.payload}static on(e,t,i){if(typeof BroadcastChannel>"u")return;const l=new BroadcastChannel("ElsieSDK/EventBus");if(i!=null&&i.eager){const s=this._lastEvent[e];s&&t(s.payload)}return l.addEventListener("message",({data:s})=>{this._identifier&&this._identifier!==s.identifier||s.event===e&&t(s.payload)}),{off(){l.close()}}}static emit(e,t){if(typeof BroadcastChannel>"u")return;const i=new BroadcastChannel("ElsieSDK/EventBus");i.postMessage({event:e,identifier:this._identifier,payload:t}),this._lastEvent[e]={payload:t},i.close()}static enableLogger(e){var t;typeof BroadcastChannel>"u"||((t=this._logger)==null||t.close(),this._logger=null,e!==!1&&(this._logger=new BroadcastChannel("ElsieSDK/EventBus"),this._logger.addEventListener("message",({data:i})=>{this._identifier&&this._identifier!==i.identifier||(console.group(`📡 Event (${i.identifier}) ➡ ${i.event}`),console.log(i.payload),console.groupEnd())})))}}r(a,"_identifier",c),r(a,"_logger",null),r(a,"_lastEvent",{});export{a as events};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/tools", "version": "0.
|
|
1
|
+
{"name": "@dropins/tools", "version": "0.37.0-alpha001"}
|
|
@@ -11,6 +11,7 @@ export * from './events-catalog';
|
|
|
11
11
|
* @property {Function} on - Subscribes to an event.
|
|
12
12
|
* @property {Function} emit - Emits an event.
|
|
13
13
|
* @property {Function} enableLogger - Enables or disables event logging.
|
|
14
|
+
* @property {Function} getLastPayload - Returns the last payload of the event.
|
|
14
15
|
*/
|
|
15
16
|
export declare class events {
|
|
16
17
|
static _identifier: string;
|
|
@@ -20,6 +21,12 @@ export declare class events {
|
|
|
20
21
|
payload: any;
|
|
21
22
|
};
|
|
22
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Returns the last payload of the event.
|
|
26
|
+
* @param event – The event to get the last payload from.
|
|
27
|
+
* @returns – The last payload of the event.
|
|
28
|
+
*/
|
|
29
|
+
static lastPayload(event: string): any;
|
|
23
30
|
/**
|
|
24
31
|
* Subscribes to an event.
|
|
25
32
|
* @param event - The event to subscribe to.
|