@forcecalendar/interface 1.0.43 → 1.0.44
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.
|
@@ -179,39 +179,35 @@ class T {
|
|
|
179
179
|
t.handler === e && this.wildcardHandlers.delete(t);
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
|
-
* Emit an event
|
|
182
|
+
* Emit an event synchronously
|
|
183
183
|
* @param {string} eventName - Event name
|
|
184
184
|
* @param {*} data - Event data
|
|
185
|
-
* @returns {Promise} Resolves when all handlers complete
|
|
186
185
|
*/
|
|
187
|
-
|
|
188
|
-
const r = [];
|
|
186
|
+
emit(e, t) {
|
|
189
187
|
if (this.events.has(e)) {
|
|
190
|
-
const
|
|
191
|
-
for (const
|
|
192
|
-
const { handler:
|
|
193
|
-
|
|
188
|
+
const s = [...this.events.get(e)];
|
|
189
|
+
for (const i of s) {
|
|
190
|
+
const { handler: n, once: o } = i;
|
|
191
|
+
o && this.off(e, n);
|
|
194
192
|
try {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
console.error(`Error in event handler for ${e}:`, c);
|
|
193
|
+
n(t, e);
|
|
194
|
+
} catch (a) {
|
|
195
|
+
console.error(`Error in event handler for ${e}:`, a);
|
|
199
196
|
}
|
|
200
197
|
}
|
|
201
198
|
}
|
|
202
|
-
const
|
|
203
|
-
for (const
|
|
204
|
-
if (this.matchesPattern(e,
|
|
205
|
-
const { handler:
|
|
206
|
-
|
|
199
|
+
const r = [];
|
|
200
|
+
for (const s of [...this.wildcardHandlers])
|
|
201
|
+
if (this.matchesPattern(e, s.pattern)) {
|
|
202
|
+
const { handler: i, once: n } = s;
|
|
203
|
+
n && r.push(s);
|
|
207
204
|
try {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
console.error(`Error in wildcard handler for ${e}:`, a);
|
|
205
|
+
i(t, e);
|
|
206
|
+
} catch (o) {
|
|
207
|
+
console.error(`Error in wildcard handler for ${e}:`, o);
|
|
212
208
|
}
|
|
213
209
|
}
|
|
214
|
-
|
|
210
|
+
r.forEach((s) => this.wildcardHandlers.delete(s));
|
|
215
211
|
}
|
|
216
212
|
/**
|
|
217
213
|
* Check if event name matches a pattern
|