@oreefy/event 1.0.0 → 2.0.0
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/README.md +5 -5
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ event.off("signedIn", listener);
|
|
|
37
37
|
event.emit("signedIn", { success: true });
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
Events
|
|
40
|
+
Events emitted via `event.emit()` work exclusively across **other** open tabs. The **current** (emitting) tab **ignores** the event and will **not trigger** its own listeners.
|
|
41
41
|
|
|
42
42
|
# API Reference
|
|
43
43
|
|
|
@@ -82,7 +82,7 @@ event.emit("theme", {
|
|
|
82
82
|
});
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
The event is
|
|
85
|
+
The event is broadcast to all other open tabs in the same origin using `BroadcastChannel`. It does not execute listeners in the originating tab.
|
|
86
86
|
|
|
87
87
|
## `idb.on()`
|
|
88
88
|
|
|
@@ -149,14 +149,14 @@ event.on("signedIn", (data) => {
|
|
|
149
149
|
});
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
The originating tab does not
|
|
152
|
+
The originating tab (Tab A) does not fire its own `on()` listeners, guaranteeing zero self-triggering side effects.
|
|
153
153
|
|
|
154
154
|
## Same-Tab vs Cross-Tab Behavior
|
|
155
155
|
|
|
156
156
|
When you call `event.emit()`
|
|
157
157
|
|
|
158
|
-
1. The event is
|
|
159
|
-
2. The event
|
|
158
|
+
1. The event payload is broadcast directly to all other open tabs via `BroadcastChannel`.
|
|
159
|
+
2. The current tab ignores the event locally, allowing your primary action handler to finish without interruption.
|
|
160
160
|
|
|
161
161
|
## Event Listener Errors
|
|
162
162
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var i=class s{static _instance;listeners=new Map;channel=new BroadcastChannel("@oreefy/idb");_triggerLocalListeners(t,e){let n=this.listeners.get(t);if(n)for(let r of n)try{r(e);}catch{}}constructor(){this.channel.addEventListener("message",t=>{let{name:e,data:n}=t.data||{};e&&this._triggerLocalListeners(e,n);});}static _initInstance(){return s._instance||(s._instance=new s),s._instance}emit(t,e){this.channel.postMessage({name:t,data:e});}on(t,e){this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e);}off(t,e){let n=this.listeners.get(t);n&&(n.delete(e),n.size===0&&this.listeners.delete(t));}},a=i._initInstance;export{a as eventInstance};
|