@xylabs/events 5.0.84 → 5.0.86
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 +402 -697
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
17
17
|
|
|
18
|
+
|
|
19
|
+
|
|
18
20
|
## Reference
|
|
19
21
|
|
|
20
22
|
**@xylabs/events**
|
|
@@ -23,28 +25,34 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
|
23
25
|
|
|
24
26
|
## Classes
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
| Class | Description |
|
|
29
|
+
| ------ | ------ |
|
|
30
|
+
| [BaseEmitter](#classes/BaseEmitter) | Base class that combines the Base utility class with typed event emission capabilities. Delegates all event operations to an internal Events instance. |
|
|
31
|
+
| [Events](#classes/Events) | Core typed event emitter implementation supporting named events, wildcard listeners, serial and concurrent emission, listener filtering, and debug logging. |
|
|
28
32
|
|
|
29
33
|
## Interfaces
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
| Interface | Description |
|
|
36
|
+
| ------ | ------ |
|
|
37
|
+
| [BaseEmitterParamsFields](#interfaces/BaseEmitterParamsFields) | Fields specific to BaseEmitter configuration parameters. |
|
|
38
|
+
| [EventEmitter](#interfaces/EventEmitter) | Interface for a typed event emitter that supports subscribing, unsubscribing, and emitting events. |
|
|
33
39
|
|
|
34
40
|
## Type Aliases
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
| Type Alias | Description |
|
|
43
|
+
| ------ | ------ |
|
|
44
|
+
| [BaseEmitterParams](#type-aliases/BaseEmitterParams) | Parameters type for configuring a BaseEmitter instance. |
|
|
45
|
+
| [DebugLogger](#type-aliases/DebugLogger) | Emittery can collect and log debug information. |
|
|
46
|
+
| [EventListenerInfo](#type-aliases/EventListenerInfo) | Information about a registered event listener, including an optional filter for selective invocation. |
|
|
47
|
+
| [DebugOptions](#type-aliases/DebugOptions) | Configure debug options of an instance. |
|
|
48
|
+
| [MetaEventData](#type-aliases/MetaEventData) | Data shape for internal meta events that fire when listeners are added or removed. |
|
|
49
|
+
| [EventsParams](#type-aliases/EventsParams) | Parameters for constructing an Events instance, with optional debug configuration. |
|
|
50
|
+
| [EventName](#type-aliases/EventName) | A valid event name, which can be any property key (string, number, or symbol). |
|
|
51
|
+
| [EventArgs](#type-aliases/EventArgs) | The allowed types for event argument payloads. |
|
|
52
|
+
| [EventData](#type-aliases/EventData) | A mapping of event names to their corresponding event argument types. |
|
|
53
|
+
| [EventUnsubscribeFunction](#type-aliases/EventUnsubscribeFunction) | A function returned by event subscription methods that unsubscribes the listener when called. |
|
|
54
|
+
| [EventAnyListener](#type-aliases/EventAnyListener) | A listener that receives all events regardless of name. |
|
|
55
|
+
| [EventListener](#type-aliases/EventListener) | A listener for a specific event type. |
|
|
48
56
|
|
|
49
57
|
### classes
|
|
50
58
|
|
|
@@ -63,13 +71,10 @@ Delegates all event operations to an internal Events instance.
|
|
|
63
71
|
|
|
64
72
|
## Type Parameters
|
|
65
73
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
`TParams` *extends* `BaseParams`
|
|
69
|
-
|
|
70
|
-
### TEventData
|
|
71
|
-
|
|
72
|
-
`TEventData` *extends* [`EventData`](#../type-aliases/EventData) = [`EventData`](#../type-aliases/EventData)
|
|
74
|
+
| Type Parameter | Default type |
|
|
75
|
+
| ------ | ------ |
|
|
76
|
+
| `TParams` *extends* `BaseParams` | `BaseParams` |
|
|
77
|
+
| `TEventData` *extends* [`EventData`](#../type-aliases/EventData) | [`EventData`](#../type-aliases/EventData) |
|
|
73
78
|
|
|
74
79
|
## Implements
|
|
75
80
|
|
|
@@ -80,14 +85,14 @@ Delegates all event operations to an internal Events instance.
|
|
|
80
85
|
### Constructor
|
|
81
86
|
|
|
82
87
|
```ts
|
|
83
|
-
new BaseEmitter<TParams, TEventData>(params): BaseEmitter<TParams, TEventData>;
|
|
88
|
+
new BaseEmitter<TParams, TEventData>(params: BaseParams<TParams>): BaseEmitter<TParams, TEventData>;
|
|
84
89
|
```
|
|
85
90
|
|
|
86
91
|
### Parameters
|
|
87
92
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
`BaseParams`\<`TParams`\>
|
|
93
|
+
| Parameter | Type |
|
|
94
|
+
| ------ | ------ |
|
|
95
|
+
| `params` | `BaseParams`\<`TParams`\> |
|
|
91
96
|
|
|
92
97
|
### Returns
|
|
93
98
|
|
|
@@ -101,59 +106,12 @@ Base<TParams>.constructor
|
|
|
101
106
|
|
|
102
107
|
## Properties
|
|
103
108
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
### Inherited from
|
|
111
|
-
|
|
112
|
-
```ts
|
|
113
|
-
Base.defaultLogger
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
***
|
|
117
|
-
|
|
118
|
-
### globalInstances
|
|
119
|
-
|
|
120
|
-
```ts
|
|
121
|
-
readonly static globalInstances: Record<BaseClassName, WeakRef<Base>[]>;
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### Inherited from
|
|
125
|
-
|
|
126
|
-
```ts
|
|
127
|
-
Base.globalInstances
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
***
|
|
131
|
-
|
|
132
|
-
### globalInstancesCountHistory
|
|
133
|
-
|
|
134
|
-
```ts
|
|
135
|
-
readonly static globalInstancesCountHistory: Record<BaseClassName, number[]>;
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Inherited from
|
|
139
|
-
|
|
140
|
-
```ts
|
|
141
|
-
Base.globalInstancesCountHistory
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
***
|
|
145
|
-
|
|
146
|
-
### eventData
|
|
147
|
-
|
|
148
|
-
```ts
|
|
149
|
-
eventData: TEventData;
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
Type-level reference to the event data shape for external type queries.
|
|
153
|
-
|
|
154
|
-
### Implementation of
|
|
155
|
-
|
|
156
|
-
[`EventEmitter`](#../interfaces/EventEmitter).[`eventData`](../interfaces/EventEmitter.md#eventdata)
|
|
109
|
+
| Property | Modifier | Type | Description | Inherited from |
|
|
110
|
+
| ------ | ------ | ------ | ------ | ------ |
|
|
111
|
+
| <a id="defaultlogger"></a> `defaultLogger?` | `static` | `Logger` | - | `Base.defaultLogger` |
|
|
112
|
+
| <a id="globalinstances"></a> `globalInstances` | `readonly` | `Record`\<`BaseClassName`, `WeakRef`\<`Base`\>[]\> | - | `Base.globalInstances` |
|
|
113
|
+
| <a id="globalinstancescounthistory"></a> `globalInstancesCountHistory` | `readonly` | `Record`\<`BaseClassName`, `number`[]\> | - | `Base.globalInstancesCountHistory` |
|
|
114
|
+
| <a id="eventdata"></a> `eventData` | `public` | `TEventData` | Type-level reference to the event data shape for external type queries. | - |
|
|
157
115
|
|
|
158
116
|
## Accessors
|
|
159
117
|
|
|
@@ -172,14 +130,14 @@ get static historyInterval(): number;
|
|
|
172
130
|
### Set Signature
|
|
173
131
|
|
|
174
132
|
```ts
|
|
175
|
-
set static historyInterval(value): void;
|
|
133
|
+
set static historyInterval(value: number): void;
|
|
176
134
|
```
|
|
177
135
|
|
|
178
136
|
#### Parameters
|
|
179
137
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
`number`
|
|
138
|
+
| Parameter | Type |
|
|
139
|
+
| ------ | ------ |
|
|
140
|
+
| `value` | `number` |
|
|
183
141
|
|
|
184
142
|
#### Returns
|
|
185
143
|
|
|
@@ -208,14 +166,14 @@ get static historyTime(): number;
|
|
|
208
166
|
### Set Signature
|
|
209
167
|
|
|
210
168
|
```ts
|
|
211
|
-
set static historyTime(value): void;
|
|
169
|
+
set static historyTime(value: number): void;
|
|
212
170
|
```
|
|
213
171
|
|
|
214
172
|
#### Parameters
|
|
215
173
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
`number`
|
|
174
|
+
| Parameter | Type |
|
|
175
|
+
| ------ | ------ |
|
|
176
|
+
| `value` | `number` |
|
|
219
177
|
|
|
220
178
|
#### Returns
|
|
221
179
|
|
|
@@ -244,14 +202,14 @@ get static maxGcFrequency(): number;
|
|
|
244
202
|
### Set Signature
|
|
245
203
|
|
|
246
204
|
```ts
|
|
247
|
-
set static maxGcFrequency(value): void;
|
|
205
|
+
set static maxGcFrequency(value: number): void;
|
|
248
206
|
```
|
|
249
207
|
|
|
250
208
|
#### Parameters
|
|
251
209
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
`number`
|
|
210
|
+
| Parameter | Type |
|
|
211
|
+
| ------ | ------ |
|
|
212
|
+
| `value` | `number` |
|
|
255
213
|
|
|
256
214
|
#### Returns
|
|
257
215
|
|
|
@@ -370,14 +328,14 @@ Base.tracer
|
|
|
370
328
|
### Call Signature
|
|
371
329
|
|
|
372
330
|
```ts
|
|
373
|
-
static gc(force
|
|
331
|
+
static gc(force?: boolean): void;
|
|
374
332
|
```
|
|
375
333
|
|
|
376
334
|
#### Parameters
|
|
377
335
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
`boolean`
|
|
336
|
+
| Parameter | Type |
|
|
337
|
+
| ------ | ------ |
|
|
338
|
+
| `force?` | `boolean` |
|
|
381
339
|
|
|
382
340
|
#### Returns
|
|
383
341
|
|
|
@@ -392,14 +350,14 @@ Base.gc
|
|
|
392
350
|
### Call Signature
|
|
393
351
|
|
|
394
352
|
```ts
|
|
395
|
-
static gc(className): void;
|
|
353
|
+
static gc(className: BaseClassName): void;
|
|
396
354
|
```
|
|
397
355
|
|
|
398
356
|
#### Parameters
|
|
399
357
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
`BaseClassName`
|
|
358
|
+
| Parameter | Type |
|
|
359
|
+
| ------ | ------ |
|
|
360
|
+
| `className` | `BaseClassName` |
|
|
403
361
|
|
|
404
362
|
#### Returns
|
|
405
363
|
|
|
@@ -416,14 +374,14 @@ Base.gc
|
|
|
416
374
|
### instanceCount()
|
|
417
375
|
|
|
418
376
|
```ts
|
|
419
|
-
static instanceCount(className): number;
|
|
377
|
+
static instanceCount(className: BaseClassName): number;
|
|
420
378
|
```
|
|
421
379
|
|
|
422
380
|
### Parameters
|
|
423
381
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
`BaseClassName`
|
|
382
|
+
| Parameter | Type |
|
|
383
|
+
| ------ | ------ |
|
|
384
|
+
| `className` | `BaseClassName` |
|
|
427
385
|
|
|
428
386
|
### Returns
|
|
429
387
|
|
|
@@ -494,18 +452,16 @@ Base.stopHistory
|
|
|
494
452
|
### clearListeners()
|
|
495
453
|
|
|
496
454
|
```ts
|
|
497
|
-
clearListeners(eventNames): BaseEmitter<TParams, TEventData>;
|
|
455
|
+
clearListeners(eventNames: keyof TEventData | keyof TEventData[]): BaseEmitter<TParams, TEventData>;
|
|
498
456
|
```
|
|
499
457
|
|
|
500
458
|
Removes all listeners for the specified event name(s).
|
|
501
459
|
|
|
502
460
|
### Parameters
|
|
503
461
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
One or more event names to clear listeners for.
|
|
507
|
-
|
|
508
|
-
keyof `TEventData` | keyof `TEventData`[]
|
|
462
|
+
| Parameter | Type | Description |
|
|
463
|
+
| ------ | ------ | ------ |
|
|
464
|
+
| `eventNames` | keyof `TEventData` \| keyof `TEventData`[] | One or more event names to clear listeners for. |
|
|
509
465
|
|
|
510
466
|
### Returns
|
|
511
467
|
|
|
@@ -522,34 +478,24 @@ This instance for chaining.
|
|
|
522
478
|
### emit()
|
|
523
479
|
|
|
524
480
|
```ts
|
|
525
|
-
emit<TEventName, TEventArgs>(eventName, eventArgs): Promise<void>;
|
|
481
|
+
emit<TEventName, TEventArgs>(eventName: TEventName, eventArgs: TEventArgs): Promise<void>;
|
|
526
482
|
```
|
|
527
483
|
|
|
528
484
|
Emits an event, invoking all registered listeners concurrently.
|
|
529
485
|
|
|
530
486
|
### Type Parameters
|
|
531
487
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
535
|
-
|
|
536
|
-
#### TEventArgs
|
|
537
|
-
|
|
538
|
-
`TEventArgs` *extends* [`EventArgs`](#../type-aliases/EventArgs) = `TEventData`\[`TEventName`\]
|
|
488
|
+
| Type Parameter | Default type |
|
|
489
|
+
| ------ | ------ |
|
|
490
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` | keyof `TEventData` |
|
|
491
|
+
| `TEventArgs` *extends* [`EventArgs`](#../type-aliases/EventArgs) | `TEventData`\[`TEventName`\] |
|
|
539
492
|
|
|
540
493
|
### Parameters
|
|
541
494
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
`TEventName`
|
|
545
|
-
|
|
546
|
-
The event to emit.
|
|
547
|
-
|
|
548
|
-
#### eventArgs
|
|
549
|
-
|
|
550
|
-
`TEventArgs`
|
|
551
|
-
|
|
552
|
-
The data to pass to listeners.
|
|
495
|
+
| Parameter | Type | Description |
|
|
496
|
+
| ------ | ------ | ------ |
|
|
497
|
+
| `eventName` | `TEventName` | The event to emit. |
|
|
498
|
+
| `eventArgs` | `TEventArgs` | The data to pass to listeners. |
|
|
553
499
|
|
|
554
500
|
### Returns
|
|
555
501
|
|
|
@@ -564,34 +510,24 @@ The data to pass to listeners.
|
|
|
564
510
|
### emitSerial()
|
|
565
511
|
|
|
566
512
|
```ts
|
|
567
|
-
emitSerial<TEventName, TEventArgs>(eventName, eventArgs): Promise<void>;
|
|
513
|
+
emitSerial<TEventName, TEventArgs>(eventName: TEventName, eventArgs: TEventArgs): Promise<void>;
|
|
568
514
|
```
|
|
569
515
|
|
|
570
516
|
Emits an event, invoking all registered listeners sequentially in order.
|
|
571
517
|
|
|
572
518
|
### Type Parameters
|
|
573
519
|
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
577
|
-
|
|
578
|
-
#### TEventArgs
|
|
579
|
-
|
|
580
|
-
`TEventArgs` *extends* [`EventArgs`](#../type-aliases/EventArgs) = `TEventData`\[`TEventName`\]
|
|
520
|
+
| Type Parameter | Default type |
|
|
521
|
+
| ------ | ------ |
|
|
522
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` | keyof `TEventData` |
|
|
523
|
+
| `TEventArgs` *extends* [`EventArgs`](#../type-aliases/EventArgs) | `TEventData`\[`TEventName`\] |
|
|
581
524
|
|
|
582
525
|
### Parameters
|
|
583
526
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
`TEventName`
|
|
587
|
-
|
|
588
|
-
The event to emit.
|
|
589
|
-
|
|
590
|
-
#### eventArgs
|
|
591
|
-
|
|
592
|
-
`TEventArgs`
|
|
593
|
-
|
|
594
|
-
The data to pass to listeners.
|
|
527
|
+
| Parameter | Type | Description |
|
|
528
|
+
| ------ | ------ | ------ |
|
|
529
|
+
| `eventName` | `TEventName` | The event to emit. |
|
|
530
|
+
| `eventArgs` | `TEventArgs` | The data to pass to listeners. |
|
|
595
531
|
|
|
596
532
|
### Returns
|
|
597
533
|
|
|
@@ -606,18 +542,16 @@ The data to pass to listeners.
|
|
|
606
542
|
### listenerCount()
|
|
607
543
|
|
|
608
544
|
```ts
|
|
609
|
-
listenerCount(eventNames): number;
|
|
545
|
+
listenerCount(eventNames: keyof TEventData | keyof TEventData[]): number;
|
|
610
546
|
```
|
|
611
547
|
|
|
612
548
|
Returns the total number of listeners registered for the specified event name(s).
|
|
613
549
|
|
|
614
550
|
### Parameters
|
|
615
551
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
One or more event names to count listeners for.
|
|
619
|
-
|
|
620
|
-
keyof `TEventData` | keyof `TEventData`[]
|
|
552
|
+
| Parameter | Type | Description |
|
|
553
|
+
| ------ | ------ | ------ |
|
|
554
|
+
| `eventNames` | keyof `TEventData` \| keyof `TEventData`[] | One or more event names to count listeners for. |
|
|
621
555
|
|
|
622
556
|
### Returns
|
|
623
557
|
|
|
@@ -634,30 +568,23 @@ The total listener count.
|
|
|
634
568
|
### off()
|
|
635
569
|
|
|
636
570
|
```ts
|
|
637
|
-
off<TEventName>(eventNames, listener): void;
|
|
571
|
+
off<TEventName>(eventNames: TEventName | TEventName[], listener: EventListener<TEventData[TEventName]>): void;
|
|
638
572
|
```
|
|
639
573
|
|
|
640
574
|
Removes a specific listener from the specified event name(s).
|
|
641
575
|
|
|
642
576
|
### Type Parameters
|
|
643
577
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
578
|
+
| Type Parameter |
|
|
579
|
+
| ------ |
|
|
580
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` |
|
|
647
581
|
|
|
648
582
|
### Parameters
|
|
649
583
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
One or more event names to unsubscribe from.
|
|
653
|
-
|
|
654
|
-
`TEventName` | `TEventName`[]
|
|
655
|
-
|
|
656
|
-
#### listener
|
|
657
|
-
|
|
658
|
-
[`EventListener`](#../type-aliases/EventListener)\<`TEventData`\[`TEventName`\]\>
|
|
659
|
-
|
|
660
|
-
The listener to remove.
|
|
584
|
+
| Parameter | Type | Description |
|
|
585
|
+
| ------ | ------ | ------ |
|
|
586
|
+
| `eventNames` | `TEventName` \| `TEventName`[] | One or more event names to unsubscribe from. |
|
|
587
|
+
| `listener` | [`EventListener`](#../type-aliases/EventListener)\<`TEventData`\[`TEventName`\]\> | The listener to remove. |
|
|
661
588
|
|
|
662
589
|
### Returns
|
|
663
590
|
|
|
@@ -672,18 +599,16 @@ The listener to remove.
|
|
|
672
599
|
### offAny()
|
|
673
600
|
|
|
674
601
|
```ts
|
|
675
|
-
offAny(listener): void;
|
|
602
|
+
offAny(listener: EventAnyListener): void;
|
|
676
603
|
```
|
|
677
604
|
|
|
678
605
|
Removes a wildcard listener that was receiving all events.
|
|
679
606
|
|
|
680
607
|
### Parameters
|
|
681
608
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
[`EventAnyListener`](#../type-aliases/EventAnyListener)
|
|
685
|
-
|
|
686
|
-
The wildcard listener to remove.
|
|
609
|
+
| Parameter | Type | Description |
|
|
610
|
+
| ------ | ------ | ------ |
|
|
611
|
+
| `listener` | [`EventAnyListener`](#../type-aliases/EventAnyListener) | The wildcard listener to remove. |
|
|
687
612
|
|
|
688
613
|
### Returns
|
|
689
614
|
|
|
@@ -698,44 +623,37 @@ The wildcard listener to remove.
|
|
|
698
623
|
### on()
|
|
699
624
|
|
|
700
625
|
```ts
|
|
701
|
-
on<TEventName>(eventNames, listener): (...args) => void;
|
|
626
|
+
on<TEventName>(eventNames: TEventName | TEventName[], listener: EventListener<TEventData[TEventName]>): (...args: []) => void;
|
|
702
627
|
```
|
|
703
628
|
|
|
704
629
|
Subscribes a listener to the specified event name(s).
|
|
705
630
|
|
|
706
631
|
### Type Parameters
|
|
707
632
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
633
|
+
| Type Parameter |
|
|
634
|
+
| ------ |
|
|
635
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` |
|
|
711
636
|
|
|
712
637
|
### Parameters
|
|
713
638
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
One or more event names to listen for.
|
|
717
|
-
|
|
718
|
-
`TEventName` | `TEventName`[]
|
|
719
|
-
|
|
720
|
-
#### listener
|
|
721
|
-
|
|
722
|
-
[`EventListener`](#../type-aliases/EventListener)\<`TEventData`\[`TEventName`\]\>
|
|
723
|
-
|
|
724
|
-
The callback to invoke when the event fires.
|
|
639
|
+
| Parameter | Type | Description |
|
|
640
|
+
| ------ | ------ | ------ |
|
|
641
|
+
| `eventNames` | `TEventName` \| `TEventName`[] | One or more event names to listen for. |
|
|
642
|
+
| `listener` | [`EventListener`](#../type-aliases/EventListener)\<`TEventData`\[`TEventName`\]\> | The callback to invoke when the event fires. |
|
|
725
643
|
|
|
726
644
|
### Returns
|
|
727
645
|
|
|
728
646
|
An unsubscribe function.
|
|
729
647
|
|
|
730
648
|
```ts
|
|
731
|
-
(...args): void;
|
|
649
|
+
(...args: []): void;
|
|
732
650
|
```
|
|
733
651
|
|
|
734
652
|
#### Parameters
|
|
735
653
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
654
|
+
| Parameter | Type |
|
|
655
|
+
| ------ | ------ |
|
|
656
|
+
| ...`args` | \[\] |
|
|
739
657
|
|
|
740
658
|
#### Returns
|
|
741
659
|
|
|
@@ -750,32 +668,30 @@ An unsubscribe function.
|
|
|
750
668
|
### onAny()
|
|
751
669
|
|
|
752
670
|
```ts
|
|
753
|
-
onAny(listener): (...args) => void;
|
|
671
|
+
onAny(listener: EventAnyListener): (...args: []) => void;
|
|
754
672
|
```
|
|
755
673
|
|
|
756
674
|
Subscribes a wildcard listener that receives all events.
|
|
757
675
|
|
|
758
676
|
### Parameters
|
|
759
677
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
[`EventAnyListener`](#../type-aliases/EventAnyListener)
|
|
763
|
-
|
|
764
|
-
The callback to invoke for any event.
|
|
678
|
+
| Parameter | Type | Description |
|
|
679
|
+
| ------ | ------ | ------ |
|
|
680
|
+
| `listener` | [`EventAnyListener`](#../type-aliases/EventAnyListener) | The callback to invoke for any event. |
|
|
765
681
|
|
|
766
682
|
### Returns
|
|
767
683
|
|
|
768
684
|
An unsubscribe function.
|
|
769
685
|
|
|
770
686
|
```ts
|
|
771
|
-
(...args): void;
|
|
687
|
+
(...args: []): void;
|
|
772
688
|
```
|
|
773
689
|
|
|
774
690
|
#### Parameters
|
|
775
691
|
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
692
|
+
| Parameter | Type |
|
|
693
|
+
| ------ | ------ |
|
|
694
|
+
| ...`args` | \[\] |
|
|
779
695
|
|
|
780
696
|
#### Returns
|
|
781
697
|
|
|
@@ -790,44 +706,37 @@ An unsubscribe function.
|
|
|
790
706
|
### once()
|
|
791
707
|
|
|
792
708
|
```ts
|
|
793
|
-
once<TEventName>(eventName, listener): (...args) => void;
|
|
709
|
+
once<TEventName>(eventName: TEventName, listener: EventListener<TEventData[TEventName]>): (...args: []) => void;
|
|
794
710
|
```
|
|
795
711
|
|
|
796
712
|
Subscribes a listener that will be invoked only once for the specified event, then automatically removed.
|
|
797
713
|
|
|
798
714
|
### Type Parameters
|
|
799
715
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
716
|
+
| Type Parameter |
|
|
717
|
+
| ------ |
|
|
718
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` |
|
|
803
719
|
|
|
804
720
|
### Parameters
|
|
805
721
|
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
`TEventName`
|
|
809
|
-
|
|
810
|
-
The event to listen for.
|
|
811
|
-
|
|
812
|
-
#### listener
|
|
813
|
-
|
|
814
|
-
[`EventListener`](#../type-aliases/EventListener)\<`TEventData`\[`TEventName`\]\>
|
|
815
|
-
|
|
816
|
-
The callback to invoke once.
|
|
722
|
+
| Parameter | Type | Description |
|
|
723
|
+
| ------ | ------ | ------ |
|
|
724
|
+
| `eventName` | `TEventName` | The event to listen for. |
|
|
725
|
+
| `listener` | [`EventListener`](#../type-aliases/EventListener)\<`TEventData`\[`TEventName`\]\> | The callback to invoke once. |
|
|
817
726
|
|
|
818
727
|
### Returns
|
|
819
728
|
|
|
820
729
|
An unsubscribe function.
|
|
821
730
|
|
|
822
731
|
```ts
|
|
823
|
-
(...args): void;
|
|
732
|
+
(...args: []): void;
|
|
824
733
|
```
|
|
825
734
|
|
|
826
735
|
#### Parameters
|
|
827
736
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
737
|
+
| Parameter | Type |
|
|
738
|
+
| ------ | ------ |
|
|
739
|
+
| ...`args` | \[\] |
|
|
831
740
|
|
|
832
741
|
#### Returns
|
|
833
742
|
|
|
@@ -852,9 +761,9 @@ serial and concurrent emission, listener filtering, and debug logging.
|
|
|
852
761
|
|
|
853
762
|
## Type Parameters
|
|
854
763
|
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
`TEventData` *extends* [`EventData`](#../type-aliases/EventData)
|
|
764
|
+
| Type Parameter | Default type |
|
|
765
|
+
| ------ | ------ |
|
|
766
|
+
| `TEventData` *extends* [`EventData`](#../type-aliases/EventData) | [`EventData`](#../type-aliases/EventData) |
|
|
858
767
|
|
|
859
768
|
## Implements
|
|
860
769
|
|
|
@@ -865,14 +774,14 @@ serial and concurrent emission, listener filtering, and debug logging.
|
|
|
865
774
|
### Constructor
|
|
866
775
|
|
|
867
776
|
```ts
|
|
868
|
-
new Events<TEventData>(params
|
|
777
|
+
new Events<TEventData>(params?: EventsParams): Events<TEventData>;
|
|
869
778
|
```
|
|
870
779
|
|
|
871
780
|
### Parameters
|
|
872
781
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
[`EventsParams`](#../type-aliases/EventsParams)
|
|
782
|
+
| Parameter | Type |
|
|
783
|
+
| ------ | ------ |
|
|
784
|
+
| `params` | [`EventsParams`](#../type-aliases/EventsParams) |
|
|
876
785
|
|
|
877
786
|
### Returns
|
|
878
787
|
|
|
@@ -886,75 +795,14 @@ Base<EventsParams>.constructor
|
|
|
886
795
|
|
|
887
796
|
## Properties
|
|
888
797
|
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
```ts
|
|
898
|
-
Base.defaultLogger
|
|
899
|
-
```
|
|
900
|
-
|
|
901
|
-
***
|
|
902
|
-
|
|
903
|
-
### globalInstances
|
|
904
|
-
|
|
905
|
-
```ts
|
|
906
|
-
readonly static globalInstances: Record<BaseClassName, WeakRef<Base>[]>;
|
|
907
|
-
```
|
|
908
|
-
|
|
909
|
-
### Inherited from
|
|
910
|
-
|
|
911
|
-
```ts
|
|
912
|
-
Base.globalInstances
|
|
913
|
-
```
|
|
914
|
-
|
|
915
|
-
***
|
|
916
|
-
|
|
917
|
-
### globalInstancesCountHistory
|
|
918
|
-
|
|
919
|
-
```ts
|
|
920
|
-
readonly static globalInstancesCountHistory: Record<BaseClassName, number[]>;
|
|
921
|
-
```
|
|
922
|
-
|
|
923
|
-
### Inherited from
|
|
924
|
-
|
|
925
|
-
```ts
|
|
926
|
-
Base.globalInstancesCountHistory
|
|
927
|
-
```
|
|
928
|
-
|
|
929
|
-
***
|
|
930
|
-
|
|
931
|
-
### anyMap
|
|
932
|
-
|
|
933
|
-
```ts
|
|
934
|
-
protected static anyMap: WeakMap<object, Set<EventAnyListener>>;
|
|
935
|
-
```
|
|
936
|
-
|
|
937
|
-
***
|
|
938
|
-
|
|
939
|
-
### eventsMap
|
|
940
|
-
|
|
941
|
-
```ts
|
|
942
|
-
protected static eventsMap: WeakMap<object, Map<PropertyKey, Set<EventListenerInfo<EventArgs>>>>;
|
|
943
|
-
```
|
|
944
|
-
|
|
945
|
-
***
|
|
946
|
-
|
|
947
|
-
### eventData
|
|
948
|
-
|
|
949
|
-
```ts
|
|
950
|
-
eventData: TEventData;
|
|
951
|
-
```
|
|
952
|
-
|
|
953
|
-
Type-level reference to the event data shape for external type queries.
|
|
954
|
-
|
|
955
|
-
### Implementation of
|
|
956
|
-
|
|
957
|
-
[`EventEmitter`](#../interfaces/EventEmitter).[`eventData`](../interfaces/EventEmitter.md#eventdata)
|
|
798
|
+
| Property | Modifier | Type | Description | Inherited from |
|
|
799
|
+
| ------ | ------ | ------ | ------ | ------ |
|
|
800
|
+
| <a id="defaultlogger"></a> `defaultLogger?` | `static` | `Logger` | - | `Base.defaultLogger` |
|
|
801
|
+
| <a id="globalinstances"></a> `globalInstances` | `readonly` | `Record`\<`BaseClassName`, `WeakRef`\<`Base`\>[]\> | - | `Base.globalInstances` |
|
|
802
|
+
| <a id="globalinstancescounthistory"></a> `globalInstancesCountHistory` | `readonly` | `Record`\<`BaseClassName`, `number`[]\> | - | `Base.globalInstancesCountHistory` |
|
|
803
|
+
| <a id="anymap"></a> `anyMap` | `static` | `WeakMap`\<`object`, `Set`\<[`EventAnyListener`](#../type-aliases/EventAnyListener)\>\> | - | - |
|
|
804
|
+
| <a id="eventsmap"></a> `eventsMap` | `static` | `WeakMap`\<`object`, `Map`\<`PropertyKey`, `Set`\<[`EventListenerInfo`](#../type-aliases/EventListenerInfo)\<[`EventArgs`](#../type-aliases/EventArgs)\>\>\>\> | - | - |
|
|
805
|
+
| <a id="eventdata"></a> `eventData` | `public` | `TEventData` | Type-level reference to the event data shape for external type queries. | - |
|
|
958
806
|
|
|
959
807
|
## Accessors
|
|
960
808
|
|
|
@@ -973,14 +821,14 @@ get static historyInterval(): number;
|
|
|
973
821
|
### Set Signature
|
|
974
822
|
|
|
975
823
|
```ts
|
|
976
|
-
set static historyInterval(value): void;
|
|
824
|
+
set static historyInterval(value: number): void;
|
|
977
825
|
```
|
|
978
826
|
|
|
979
827
|
#### Parameters
|
|
980
828
|
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
`number`
|
|
829
|
+
| Parameter | Type |
|
|
830
|
+
| ------ | ------ |
|
|
831
|
+
| `value` | `number` |
|
|
984
832
|
|
|
985
833
|
#### Returns
|
|
986
834
|
|
|
@@ -1009,14 +857,14 @@ get static historyTime(): number;
|
|
|
1009
857
|
### Set Signature
|
|
1010
858
|
|
|
1011
859
|
```ts
|
|
1012
|
-
set static historyTime(value): void;
|
|
860
|
+
set static historyTime(value: number): void;
|
|
1013
861
|
```
|
|
1014
862
|
|
|
1015
863
|
#### Parameters
|
|
1016
864
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
`number`
|
|
865
|
+
| Parameter | Type |
|
|
866
|
+
| ------ | ------ |
|
|
867
|
+
| `value` | `number` |
|
|
1020
868
|
|
|
1021
869
|
#### Returns
|
|
1022
870
|
|
|
@@ -1045,14 +893,14 @@ get static maxGcFrequency(): number;
|
|
|
1045
893
|
### Set Signature
|
|
1046
894
|
|
|
1047
895
|
```ts
|
|
1048
|
-
set static maxGcFrequency(value): void;
|
|
896
|
+
set static maxGcFrequency(value: number): void;
|
|
1049
897
|
```
|
|
1050
898
|
|
|
1051
899
|
#### Parameters
|
|
1052
900
|
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
`number`
|
|
901
|
+
| Parameter | Type |
|
|
902
|
+
| ------ | ------ |
|
|
903
|
+
| `value` | `number` |
|
|
1056
904
|
|
|
1057
905
|
#### Returns
|
|
1058
906
|
|
|
@@ -1183,14 +1031,14 @@ Whether debug mode is enabled globally or via the DEBUG environment variable.
|
|
|
1183
1031
|
### Set Signature
|
|
1184
1032
|
|
|
1185
1033
|
```ts
|
|
1186
|
-
set static isDebugEnabled(newValue): void;
|
|
1034
|
+
set static isDebugEnabled(newValue: boolean): void;
|
|
1187
1035
|
```
|
|
1188
1036
|
|
|
1189
1037
|
#### Parameters
|
|
1190
1038
|
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
`boolean`
|
|
1039
|
+
| Parameter | Type |
|
|
1040
|
+
| ------ | ------ |
|
|
1041
|
+
| `newValue` | `boolean` |
|
|
1194
1042
|
|
|
1195
1043
|
#### Returns
|
|
1196
1044
|
|
|
@@ -1219,14 +1067,14 @@ The debug configuration for this instance, if provided.
|
|
|
1219
1067
|
### Call Signature
|
|
1220
1068
|
|
|
1221
1069
|
```ts
|
|
1222
|
-
static gc(force
|
|
1070
|
+
static gc(force?: boolean): void;
|
|
1223
1071
|
```
|
|
1224
1072
|
|
|
1225
1073
|
#### Parameters
|
|
1226
1074
|
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
`boolean`
|
|
1075
|
+
| Parameter | Type |
|
|
1076
|
+
| ------ | ------ |
|
|
1077
|
+
| `force?` | `boolean` |
|
|
1230
1078
|
|
|
1231
1079
|
#### Returns
|
|
1232
1080
|
|
|
@@ -1241,14 +1089,14 @@ Base.gc
|
|
|
1241
1089
|
### Call Signature
|
|
1242
1090
|
|
|
1243
1091
|
```ts
|
|
1244
|
-
static gc(className): void;
|
|
1092
|
+
static gc(className: BaseClassName): void;
|
|
1245
1093
|
```
|
|
1246
1094
|
|
|
1247
1095
|
#### Parameters
|
|
1248
1096
|
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
`BaseClassName`
|
|
1097
|
+
| Parameter | Type |
|
|
1098
|
+
| ------ | ------ |
|
|
1099
|
+
| `className` | `BaseClassName` |
|
|
1252
1100
|
|
|
1253
1101
|
#### Returns
|
|
1254
1102
|
|
|
@@ -1265,14 +1113,14 @@ Base.gc
|
|
|
1265
1113
|
### instanceCount()
|
|
1266
1114
|
|
|
1267
1115
|
```ts
|
|
1268
|
-
static instanceCount(className): number;
|
|
1116
|
+
static instanceCount(className: BaseClassName): number;
|
|
1269
1117
|
```
|
|
1270
1118
|
|
|
1271
1119
|
### Parameters
|
|
1272
1120
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
`BaseClassName`
|
|
1121
|
+
| Parameter | Type |
|
|
1122
|
+
| ------ | ------ |
|
|
1123
|
+
| `className` | `BaseClassName` |
|
|
1276
1124
|
|
|
1277
1125
|
### Returns
|
|
1278
1126
|
|
|
@@ -1343,18 +1191,16 @@ Base.stopHistory
|
|
|
1343
1191
|
### clearListeners()
|
|
1344
1192
|
|
|
1345
1193
|
```ts
|
|
1346
|
-
clearListeners(eventNames): void;
|
|
1194
|
+
clearListeners(eventNames: keyof TEventData | keyof TEventData[]): void;
|
|
1347
1195
|
```
|
|
1348
1196
|
|
|
1349
1197
|
Removes all listeners for the specified event name(s).
|
|
1350
1198
|
|
|
1351
1199
|
### Parameters
|
|
1352
1200
|
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
One or more event names to clear listeners for.
|
|
1356
|
-
|
|
1357
|
-
keyof `TEventData` | keyof `TEventData`[]
|
|
1201
|
+
| Parameter | Type | Description |
|
|
1202
|
+
| ------ | ------ | ------ |
|
|
1203
|
+
| `eventNames` | keyof `TEventData` \| keyof `TEventData`[] | One or more event names to clear listeners for. |
|
|
1358
1204
|
|
|
1359
1205
|
### Returns
|
|
1360
1206
|
|
|
@@ -1369,30 +1215,23 @@ keyof `TEventData` | keyof `TEventData`[]
|
|
|
1369
1215
|
### emit()
|
|
1370
1216
|
|
|
1371
1217
|
```ts
|
|
1372
|
-
emit<TEventName>(eventName, eventArgs): Promise<void>;
|
|
1218
|
+
emit<TEventName>(eventName: TEventName, eventArgs: TEventData[TEventName]): Promise<void>;
|
|
1373
1219
|
```
|
|
1374
1220
|
|
|
1375
1221
|
Emits an event, invoking all registered listeners concurrently.
|
|
1376
1222
|
|
|
1377
1223
|
### Type Parameters
|
|
1378
1224
|
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
1225
|
+
| Type Parameter |
|
|
1226
|
+
| ------ |
|
|
1227
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` |
|
|
1382
1228
|
|
|
1383
1229
|
### Parameters
|
|
1384
1230
|
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
`TEventName`
|
|
1388
|
-
|
|
1389
|
-
The event to emit.
|
|
1390
|
-
|
|
1391
|
-
#### eventArgs
|
|
1392
|
-
|
|
1393
|
-
`TEventData`\[`TEventName`\]
|
|
1394
|
-
|
|
1395
|
-
The data to pass to listeners.
|
|
1231
|
+
| Parameter | Type | Description |
|
|
1232
|
+
| ------ | ------ | ------ |
|
|
1233
|
+
| `eventName` | `TEventName` | The event to emit. |
|
|
1234
|
+
| `eventArgs` | `TEventData`\[`TEventName`\] | The data to pass to listeners. |
|
|
1396
1235
|
|
|
1397
1236
|
### Returns
|
|
1398
1237
|
|
|
@@ -1407,30 +1246,23 @@ The data to pass to listeners.
|
|
|
1407
1246
|
### emitMetaEvent()
|
|
1408
1247
|
|
|
1409
1248
|
```ts
|
|
1410
|
-
emitMetaEvent<TEventName>(eventName, eventArgs): Promise<boolean | undefined>;
|
|
1249
|
+
emitMetaEvent<TEventName>(eventName: TEventName, eventArgs: MetaEventData<TEventData>[TEventName]): Promise<boolean | undefined>;
|
|
1411
1250
|
```
|
|
1412
1251
|
|
|
1413
1252
|
Emits an internal meta event (listenerAdded or listenerRemoved).
|
|
1414
1253
|
|
|
1415
1254
|
### Type Parameters
|
|
1416
1255
|
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
`TEventName` *extends* keyof [`MetaEventData`](#../type-aliases/MetaEventData)\<`TEventData`\>
|
|
1256
|
+
| Type Parameter |
|
|
1257
|
+
| ------ |
|
|
1258
|
+
| `TEventName` *extends* keyof [`MetaEventData`](#../type-aliases/MetaEventData)\<`TEventData`\> |
|
|
1420
1259
|
|
|
1421
1260
|
### Parameters
|
|
1422
1261
|
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
`TEventName`
|
|
1426
|
-
|
|
1427
|
-
The meta event name.
|
|
1428
|
-
|
|
1429
|
-
#### eventArgs
|
|
1430
|
-
|
|
1431
|
-
[`MetaEventData`](#../type-aliases/MetaEventData)\<`TEventData`\>\[`TEventName`\]
|
|
1432
|
-
|
|
1433
|
-
The meta event data containing listener and event information.
|
|
1262
|
+
| Parameter | Type | Description |
|
|
1263
|
+
| ------ | ------ | ------ |
|
|
1264
|
+
| `eventName` | `TEventName` | The meta event name. |
|
|
1265
|
+
| `eventArgs` | [`MetaEventData`](#../type-aliases/MetaEventData)\<`TEventData`\>\[`TEventName`\] | The meta event data containing listener and event information. |
|
|
1434
1266
|
|
|
1435
1267
|
### Returns
|
|
1436
1268
|
|
|
@@ -1443,30 +1275,23 @@ True if the meta event was emitted successfully.
|
|
|
1443
1275
|
### emitSerial()
|
|
1444
1276
|
|
|
1445
1277
|
```ts
|
|
1446
|
-
emitSerial<TEventName>(eventName, eventArgs): Promise<void>;
|
|
1278
|
+
emitSerial<TEventName>(eventName: TEventName, eventArgs: TEventData[TEventName]): Promise<void>;
|
|
1447
1279
|
```
|
|
1448
1280
|
|
|
1449
1281
|
Emits an event, invoking all registered listeners sequentially in order.
|
|
1450
1282
|
|
|
1451
1283
|
### Type Parameters
|
|
1452
1284
|
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
1285
|
+
| Type Parameter |
|
|
1286
|
+
| ------ |
|
|
1287
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` |
|
|
1456
1288
|
|
|
1457
1289
|
### Parameters
|
|
1458
1290
|
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
`TEventName`
|
|
1462
|
-
|
|
1463
|
-
The event to emit.
|
|
1464
|
-
|
|
1465
|
-
#### eventArgs
|
|
1466
|
-
|
|
1467
|
-
`TEventData`\[`TEventName`\]
|
|
1468
|
-
|
|
1469
|
-
The data to pass to listeners.
|
|
1291
|
+
| Parameter | Type | Description |
|
|
1292
|
+
| ------ | ------ | ------ |
|
|
1293
|
+
| `eventName` | `TEventName` | The event to emit. |
|
|
1294
|
+
| `eventArgs` | `TEventData`\[`TEventName`\] | The data to pass to listeners. |
|
|
1470
1295
|
|
|
1471
1296
|
### Returns
|
|
1472
1297
|
|
|
@@ -1481,18 +1306,16 @@ The data to pass to listeners.
|
|
|
1481
1306
|
### listenerCount()
|
|
1482
1307
|
|
|
1483
1308
|
```ts
|
|
1484
|
-
listenerCount(eventNames
|
|
1309
|
+
listenerCount(eventNames?: keyof TEventData | keyof TEventData[]): number;
|
|
1485
1310
|
```
|
|
1486
1311
|
|
|
1487
1312
|
Returns the total number of listeners registered for the specified event name(s).
|
|
1488
1313
|
|
|
1489
1314
|
### Parameters
|
|
1490
1315
|
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
One or more event names to count listeners for.
|
|
1494
|
-
|
|
1495
|
-
keyof `TEventData` | keyof `TEventData`[]
|
|
1316
|
+
| Parameter | Type | Description |
|
|
1317
|
+
| ------ | ------ | ------ |
|
|
1318
|
+
| `eventNames?` | keyof `TEventData` \| keyof `TEventData`[] | One or more event names to count listeners for. |
|
|
1496
1319
|
|
|
1497
1320
|
### Returns
|
|
1498
1321
|
|
|
@@ -1510,38 +1333,26 @@ The total listener count.
|
|
|
1510
1333
|
|
|
1511
1334
|
```ts
|
|
1512
1335
|
logIfDebugEnabled<TEventName>(
|
|
1513
|
-
type,
|
|
1514
|
-
eventName
|
|
1515
|
-
eventArgs
|
|
1336
|
+
type: string,
|
|
1337
|
+
eventName?: TEventName,
|
|
1338
|
+
eventArgs?: EventArgs): void;
|
|
1516
1339
|
```
|
|
1517
1340
|
|
|
1518
1341
|
Logs debug information if debug mode is enabled.
|
|
1519
1342
|
|
|
1520
1343
|
### Type Parameters
|
|
1521
1344
|
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
`TEventName` *extends* `PropertyKey`
|
|
1345
|
+
| Type Parameter |
|
|
1346
|
+
| ------ |
|
|
1347
|
+
| `TEventName` *extends* `PropertyKey` |
|
|
1525
1348
|
|
|
1526
1349
|
### Parameters
|
|
1527
1350
|
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
`string`
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
#### eventName?
|
|
1535
|
-
|
|
1536
|
-
`TEventName`
|
|
1537
|
-
|
|
1538
|
-
The event name, if applicable.
|
|
1539
|
-
|
|
1540
|
-
#### eventArgs?
|
|
1541
|
-
|
|
1542
|
-
[`EventArgs`](#../type-aliases/EventArgs)
|
|
1543
|
-
|
|
1544
|
-
The event data, if applicable.
|
|
1351
|
+
| Parameter | Type | Description |
|
|
1352
|
+
| ------ | ------ | ------ |
|
|
1353
|
+
| `type` | `string` | The type of operation being logged. |
|
|
1354
|
+
| `eventName?` | `TEventName` | The event name, if applicable. |
|
|
1355
|
+
| `eventArgs?` | [`EventArgs`](#../type-aliases/EventArgs) | The event data, if applicable. |
|
|
1545
1356
|
|
|
1546
1357
|
### Returns
|
|
1547
1358
|
|
|
@@ -1552,34 +1363,24 @@ The event data, if applicable.
|
|
|
1552
1363
|
### off()
|
|
1553
1364
|
|
|
1554
1365
|
```ts
|
|
1555
|
-
off<TEventName, TEventListener>(eventNames, listener): void;
|
|
1366
|
+
off<TEventName, TEventListener>(eventNames: TEventName | TEventName[], listener: TEventListener): void;
|
|
1556
1367
|
```
|
|
1557
1368
|
|
|
1558
1369
|
Removes a specific listener from the specified event name(s).
|
|
1559
1370
|
|
|
1560
1371
|
### Type Parameters
|
|
1561
1372
|
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
1565
|
-
|
|
1566
|
-
#### TEventListener
|
|
1567
|
-
|
|
1568
|
-
`TEventListener` = [`EventListener`](#../type-aliases/EventListener)\<`TEventData`\[`TEventName`\]\>
|
|
1373
|
+
| Type Parameter | Default type |
|
|
1374
|
+
| ------ | ------ |
|
|
1375
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` | - |
|
|
1376
|
+
| `TEventListener` | [`EventListener`](#../type-aliases/EventListener)\<`TEventData`\[`TEventName`\]\> |
|
|
1569
1377
|
|
|
1570
1378
|
### Parameters
|
|
1571
1379
|
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
One or more event names to unsubscribe from.
|
|
1575
|
-
|
|
1576
|
-
`TEventName` | `TEventName`[]
|
|
1577
|
-
|
|
1578
|
-
#### listener
|
|
1579
|
-
|
|
1580
|
-
`TEventListener`
|
|
1581
|
-
|
|
1582
|
-
The listener to remove.
|
|
1380
|
+
| Parameter | Type | Description |
|
|
1381
|
+
| ------ | ------ | ------ |
|
|
1382
|
+
| `eventNames` | `TEventName` \| `TEventName`[] | One or more event names to unsubscribe from. |
|
|
1383
|
+
| `listener` | `TEventListener` | The listener to remove. |
|
|
1583
1384
|
|
|
1584
1385
|
### Returns
|
|
1585
1386
|
|
|
@@ -1594,18 +1395,16 @@ The listener to remove.
|
|
|
1594
1395
|
### offAny()
|
|
1595
1396
|
|
|
1596
1397
|
```ts
|
|
1597
|
-
offAny(listener): void;
|
|
1398
|
+
offAny(listener: EventAnyListener): void;
|
|
1598
1399
|
```
|
|
1599
1400
|
|
|
1600
1401
|
Removes a wildcard listener that was receiving all events.
|
|
1601
1402
|
|
|
1602
1403
|
### Parameters
|
|
1603
1404
|
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
[`EventAnyListener`](#../type-aliases/EventAnyListener)
|
|
1607
|
-
|
|
1608
|
-
The wildcard listener to remove.
|
|
1405
|
+
| Parameter | Type | Description |
|
|
1406
|
+
| ------ | ------ | ------ |
|
|
1407
|
+
| `listener` | [`EventAnyListener`](#../type-aliases/EventAnyListener) | The wildcard listener to remove. |
|
|
1609
1408
|
|
|
1610
1409
|
### Returns
|
|
1611
1410
|
|
|
@@ -1621,52 +1420,40 @@ The wildcard listener to remove.
|
|
|
1621
1420
|
|
|
1622
1421
|
```ts
|
|
1623
1422
|
on<TEventName>(
|
|
1624
|
-
eventNames,
|
|
1625
|
-
listener
|
|
1626
|
-
filter
|
|
1423
|
+
eventNames: TEventName | TEventName[],
|
|
1424
|
+
listener: EventListener<TEventData[TEventName]>,
|
|
1425
|
+
filter?: TEventData[TEventName]): (...args: []) => void;
|
|
1627
1426
|
```
|
|
1628
1427
|
|
|
1629
1428
|
Subscribes a listener to the specified event name(s).
|
|
1630
1429
|
|
|
1631
1430
|
### Type Parameters
|
|
1632
1431
|
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
1432
|
+
| Type Parameter | Default type |
|
|
1433
|
+
| ------ | ------ |
|
|
1434
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` | keyof `TEventData` |
|
|
1636
1435
|
|
|
1637
1436
|
### Parameters
|
|
1638
1437
|
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
One or more event names to listen for.
|
|
1642
|
-
|
|
1643
|
-
`
|
|
1644
|
-
|
|
1645
|
-
#### listener
|
|
1646
|
-
|
|
1647
|
-
[`EventListener`](#../type-aliases/EventListener)\<`TEventData`\[`TEventName`\]\>
|
|
1648
|
-
|
|
1649
|
-
The callback to invoke when the event fires.
|
|
1650
|
-
|
|
1651
|
-
#### filter?
|
|
1652
|
-
|
|
1653
|
-
`TEventData`\[`TEventName`\]
|
|
1654
|
-
|
|
1655
|
-
Optional filter to selectively invoke the listener based on event data.
|
|
1438
|
+
| Parameter | Type | Description |
|
|
1439
|
+
| ------ | ------ | ------ |
|
|
1440
|
+
| `eventNames` | `TEventName` \| `TEventName`[] | One or more event names to listen for. |
|
|
1441
|
+
| `listener` | [`EventListener`](#../type-aliases/EventListener)\<`TEventData`\[`TEventName`\]\> | The callback to invoke when the event fires. |
|
|
1442
|
+
| `filter?` | `TEventData`\[`TEventName`\] | Optional filter to selectively invoke the listener based on event data. |
|
|
1656
1443
|
|
|
1657
1444
|
### Returns
|
|
1658
1445
|
|
|
1659
1446
|
An unsubscribe function.
|
|
1660
1447
|
|
|
1661
1448
|
```ts
|
|
1662
|
-
(...args): void;
|
|
1449
|
+
(...args: []): void;
|
|
1663
1450
|
```
|
|
1664
1451
|
|
|
1665
1452
|
#### Parameters
|
|
1666
1453
|
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1454
|
+
| Parameter | Type |
|
|
1455
|
+
| ------ | ------ |
|
|
1456
|
+
| ...`args` | \[\] |
|
|
1670
1457
|
|
|
1671
1458
|
#### Returns
|
|
1672
1459
|
|
|
@@ -1681,32 +1468,30 @@ An unsubscribe function.
|
|
|
1681
1468
|
### onAny()
|
|
1682
1469
|
|
|
1683
1470
|
```ts
|
|
1684
|
-
onAny(listener): (...args) => void;
|
|
1471
|
+
onAny(listener: EventAnyListener): (...args: []) => void;
|
|
1685
1472
|
```
|
|
1686
1473
|
|
|
1687
1474
|
Subscribes a wildcard listener that receives all events.
|
|
1688
1475
|
|
|
1689
1476
|
### Parameters
|
|
1690
1477
|
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
[`EventAnyListener`](#../type-aliases/EventAnyListener)
|
|
1694
|
-
|
|
1695
|
-
The callback to invoke for any event.
|
|
1478
|
+
| Parameter | Type | Description |
|
|
1479
|
+
| ------ | ------ | ------ |
|
|
1480
|
+
| `listener` | [`EventAnyListener`](#../type-aliases/EventAnyListener) | The callback to invoke for any event. |
|
|
1696
1481
|
|
|
1697
1482
|
### Returns
|
|
1698
1483
|
|
|
1699
1484
|
An unsubscribe function.
|
|
1700
1485
|
|
|
1701
1486
|
```ts
|
|
1702
|
-
(...args): void;
|
|
1487
|
+
(...args: []): void;
|
|
1703
1488
|
```
|
|
1704
1489
|
|
|
1705
1490
|
#### Parameters
|
|
1706
1491
|
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1492
|
+
| Parameter | Type |
|
|
1493
|
+
| ------ | ------ |
|
|
1494
|
+
| ...`args` | \[\] |
|
|
1710
1495
|
|
|
1711
1496
|
#### Returns
|
|
1712
1497
|
|
|
@@ -1721,44 +1506,37 @@ An unsubscribe function.
|
|
|
1721
1506
|
### once()
|
|
1722
1507
|
|
|
1723
1508
|
```ts
|
|
1724
|
-
once<TEventName>(eventName, listener): (...args) => void;
|
|
1509
|
+
once<TEventName>(eventName: TEventName, listener: EventListener<TEventData[TEventName]>): (...args: []) => void;
|
|
1725
1510
|
```
|
|
1726
1511
|
|
|
1727
1512
|
Subscribes a listener that will be invoked only once for the specified event, then automatically removed.
|
|
1728
1513
|
|
|
1729
1514
|
### Type Parameters
|
|
1730
1515
|
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
1516
|
+
| Type Parameter |
|
|
1517
|
+
| ------ |
|
|
1518
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` |
|
|
1734
1519
|
|
|
1735
1520
|
### Parameters
|
|
1736
1521
|
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
`TEventName`
|
|
1740
|
-
|
|
1741
|
-
The event to listen for.
|
|
1742
|
-
|
|
1743
|
-
#### listener
|
|
1744
|
-
|
|
1745
|
-
[`EventListener`](#../type-aliases/EventListener)\<`TEventData`\[`TEventName`\]\>
|
|
1746
|
-
|
|
1747
|
-
The callback to invoke once.
|
|
1522
|
+
| Parameter | Type | Description |
|
|
1523
|
+
| ------ | ------ | ------ |
|
|
1524
|
+
| `eventName` | `TEventName` | The event to listen for. |
|
|
1525
|
+
| `listener` | [`EventListener`](#../type-aliases/EventListener)\<`TEventData`\[`TEventName`\]\> | The callback to invoke once. |
|
|
1748
1526
|
|
|
1749
1527
|
### Returns
|
|
1750
1528
|
|
|
1751
1529
|
An unsubscribe function.
|
|
1752
1530
|
|
|
1753
1531
|
```ts
|
|
1754
|
-
(...args): void;
|
|
1532
|
+
(...args: []): void;
|
|
1755
1533
|
```
|
|
1756
1534
|
|
|
1757
1535
|
#### Parameters
|
|
1758
1536
|
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1537
|
+
| Parameter | Type |
|
|
1538
|
+
| ------ | ------ |
|
|
1539
|
+
| ...`args` | \[\] |
|
|
1762
1540
|
|
|
1763
1541
|
#### Returns
|
|
1764
1542
|
|
|
@@ -1788,35 +1566,31 @@ Interface for a typed event emitter that supports subscribing, unsubscribing, an
|
|
|
1788
1566
|
|
|
1789
1567
|
## Type Parameters
|
|
1790
1568
|
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
`T` *extends* [`EventData`](#../type-aliases/EventData)
|
|
1569
|
+
| Type Parameter |
|
|
1570
|
+
| ------ |
|
|
1571
|
+
| `T` *extends* [`EventData`](#../type-aliases/EventData) |
|
|
1794
1572
|
|
|
1795
1573
|
## Properties
|
|
1796
1574
|
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
eventData: T;
|
|
1801
|
-
```
|
|
1802
|
-
|
|
1803
|
-
Type-level reference to the event data shape for external type queries.
|
|
1575
|
+
| Property | Type | Description |
|
|
1576
|
+
| ------ | ------ | ------ |
|
|
1577
|
+
| <a id="eventdata"></a> `eventData` | `T` | Type-level reference to the event data shape for external type queries. |
|
|
1804
1578
|
|
|
1805
1579
|
## Methods
|
|
1806
1580
|
|
|
1807
1581
|
### clearListeners()
|
|
1808
1582
|
|
|
1809
1583
|
```ts
|
|
1810
|
-
clearListeners(eventNames): void;
|
|
1584
|
+
clearListeners(eventNames: keyof T | keyof T[]): void;
|
|
1811
1585
|
```
|
|
1812
1586
|
|
|
1813
1587
|
Removes all listeners for the specified event name(s).
|
|
1814
1588
|
|
|
1815
1589
|
### Parameters
|
|
1816
1590
|
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
keyof `T`
|
|
1591
|
+
| Parameter | Type |
|
|
1592
|
+
| ------ | ------ |
|
|
1593
|
+
| `eventNames` | keyof `T` \| keyof `T`[] |
|
|
1820
1594
|
|
|
1821
1595
|
### Returns
|
|
1822
1596
|
|
|
@@ -1827,26 +1601,23 @@ keyof `T` | keyof `T`[]
|
|
|
1827
1601
|
### emit()
|
|
1828
1602
|
|
|
1829
1603
|
```ts
|
|
1830
|
-
emit<TEventName>(eventName, eventArgs): Promise<void>;
|
|
1604
|
+
emit<TEventName>(eventName: TEventName, eventArgs: T[TEventName]): Promise<void>;
|
|
1831
1605
|
```
|
|
1832
1606
|
|
|
1833
1607
|
Emits an event, invoking all registered listeners concurrently.
|
|
1834
1608
|
|
|
1835
1609
|
### Type Parameters
|
|
1836
1610
|
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
1611
|
+
| Type Parameter |
|
|
1612
|
+
| ------ |
|
|
1613
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` |
|
|
1840
1614
|
|
|
1841
1615
|
### Parameters
|
|
1842
1616
|
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
`TEventName`
|
|
1846
|
-
|
|
1847
|
-
#### eventArgs
|
|
1848
|
-
|
|
1849
|
-
`T`\[`TEventName`\]
|
|
1617
|
+
| Parameter | Type |
|
|
1618
|
+
| ------ | ------ |
|
|
1619
|
+
| `eventName` | `TEventName` |
|
|
1620
|
+
| `eventArgs` | `T`\[`TEventName`\] |
|
|
1850
1621
|
|
|
1851
1622
|
### Returns
|
|
1852
1623
|
|
|
@@ -1857,26 +1628,23 @@ Emits an event, invoking all registered listeners concurrently.
|
|
|
1857
1628
|
### emitSerial()
|
|
1858
1629
|
|
|
1859
1630
|
```ts
|
|
1860
|
-
emitSerial<TEventName>(eventName, eventArgs): Promise<void>;
|
|
1631
|
+
emitSerial<TEventName>(eventName: TEventName, eventArgs: T[TEventName]): Promise<void>;
|
|
1861
1632
|
```
|
|
1862
1633
|
|
|
1863
1634
|
Emits an event, invoking all registered listeners sequentially in order.
|
|
1864
1635
|
|
|
1865
1636
|
### Type Parameters
|
|
1866
1637
|
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
1638
|
+
| Type Parameter |
|
|
1639
|
+
| ------ |
|
|
1640
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` |
|
|
1870
1641
|
|
|
1871
1642
|
### Parameters
|
|
1872
1643
|
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
`TEventName`
|
|
1876
|
-
|
|
1877
|
-
#### eventArgs
|
|
1878
|
-
|
|
1879
|
-
`T`\[`TEventName`\]
|
|
1644
|
+
| Parameter | Type |
|
|
1645
|
+
| ------ | ------ |
|
|
1646
|
+
| `eventName` | `TEventName` |
|
|
1647
|
+
| `eventArgs` | `T`\[`TEventName`\] |
|
|
1880
1648
|
|
|
1881
1649
|
### Returns
|
|
1882
1650
|
|
|
@@ -1887,16 +1655,16 @@ Emits an event, invoking all registered listeners sequentially in order.
|
|
|
1887
1655
|
### listenerCount()
|
|
1888
1656
|
|
|
1889
1657
|
```ts
|
|
1890
|
-
listenerCount(eventNames): number;
|
|
1658
|
+
listenerCount(eventNames: keyof T | keyof T[]): number;
|
|
1891
1659
|
```
|
|
1892
1660
|
|
|
1893
1661
|
Returns the total number of listeners registered for the specified event name(s).
|
|
1894
1662
|
|
|
1895
1663
|
### Parameters
|
|
1896
1664
|
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
keyof `T`
|
|
1665
|
+
| Parameter | Type |
|
|
1666
|
+
| ------ | ------ |
|
|
1667
|
+
| `eventNames` | keyof `T` \| keyof `T`[] |
|
|
1900
1668
|
|
|
1901
1669
|
### Returns
|
|
1902
1670
|
|
|
@@ -1907,26 +1675,23 @@ keyof `T` | keyof `T`[]
|
|
|
1907
1675
|
### off()
|
|
1908
1676
|
|
|
1909
1677
|
```ts
|
|
1910
|
-
off<TEventName>(eventNames, listener): void;
|
|
1678
|
+
off<TEventName>(eventNames: TEventName | TEventName[], listener: EventListener<T[TEventName]>): void;
|
|
1911
1679
|
```
|
|
1912
1680
|
|
|
1913
1681
|
Removes a specific listener from the specified event name(s).
|
|
1914
1682
|
|
|
1915
1683
|
### Type Parameters
|
|
1916
1684
|
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
1685
|
+
| Type Parameter |
|
|
1686
|
+
| ------ |
|
|
1687
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` |
|
|
1920
1688
|
|
|
1921
1689
|
### Parameters
|
|
1922
1690
|
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
`
|
|
1926
|
-
|
|
1927
|
-
#### listener
|
|
1928
|
-
|
|
1929
|
-
[`EventListener`](#../type-aliases/EventListener)\<`T`\[`TEventName`\]\>
|
|
1691
|
+
| Parameter | Type |
|
|
1692
|
+
| ------ | ------ |
|
|
1693
|
+
| `eventNames` | `TEventName` \| `TEventName`[] |
|
|
1694
|
+
| `listener` | [`EventListener`](#../type-aliases/EventListener)\<`T`\[`TEventName`\]\> |
|
|
1930
1695
|
|
|
1931
1696
|
### Returns
|
|
1932
1697
|
|
|
@@ -1937,16 +1702,18 @@ Removes a specific listener from the specified event name(s).
|
|
|
1937
1702
|
### offAny()
|
|
1938
1703
|
|
|
1939
1704
|
```ts
|
|
1940
|
-
offAny(listener
|
|
1705
|
+
offAny(listener:
|
|
1706
|
+
| Promise<void>
|
|
1707
|
+
| EventAnyListener): void;
|
|
1941
1708
|
```
|
|
1942
1709
|
|
|
1943
1710
|
Removes a wildcard listener that was receiving all events.
|
|
1944
1711
|
|
|
1945
1712
|
### Parameters
|
|
1946
1713
|
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
`Promise`\<`void`\>
|
|
1714
|
+
| Parameter | Type |
|
|
1715
|
+
| ------ | ------ |
|
|
1716
|
+
| `listener` | \| `Promise`\<`void`\> \| [`EventAnyListener`](#../type-aliases/EventAnyListener) |
|
|
1950
1717
|
|
|
1951
1718
|
### Returns
|
|
1952
1719
|
|
|
@@ -1957,26 +1724,23 @@ Removes a wildcard listener that was receiving all events.
|
|
|
1957
1724
|
### on()
|
|
1958
1725
|
|
|
1959
1726
|
```ts
|
|
1960
|
-
on<TEventName>(eventNames, listener): EventUnsubscribeFunction;
|
|
1727
|
+
on<TEventName>(eventNames: TEventName | TEventName[], listener: EventListener<T[TEventName]>): EventUnsubscribeFunction;
|
|
1961
1728
|
```
|
|
1962
1729
|
|
|
1963
1730
|
Subscribes a listener to the specified event name(s) and returns an unsubscribe function.
|
|
1964
1731
|
|
|
1965
1732
|
### Type Parameters
|
|
1966
1733
|
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
1734
|
+
| Type Parameter |
|
|
1735
|
+
| ------ |
|
|
1736
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` |
|
|
1970
1737
|
|
|
1971
1738
|
### Parameters
|
|
1972
1739
|
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
`
|
|
1976
|
-
|
|
1977
|
-
#### listener
|
|
1978
|
-
|
|
1979
|
-
[`EventListener`](#../type-aliases/EventListener)\<`T`\[`TEventName`\]\>
|
|
1740
|
+
| Parameter | Type |
|
|
1741
|
+
| ------ | ------ |
|
|
1742
|
+
| `eventNames` | `TEventName` \| `TEventName`[] |
|
|
1743
|
+
| `listener` | [`EventListener`](#../type-aliases/EventListener)\<`T`\[`TEventName`\]\> |
|
|
1980
1744
|
|
|
1981
1745
|
### Returns
|
|
1982
1746
|
|
|
@@ -1987,16 +1751,16 @@ Subscribes a listener to the specified event name(s) and returns an unsubscribe
|
|
|
1987
1751
|
### onAny()
|
|
1988
1752
|
|
|
1989
1753
|
```ts
|
|
1990
|
-
onAny(listener): EventUnsubscribeFunction;
|
|
1754
|
+
onAny(listener: EventAnyListener): EventUnsubscribeFunction;
|
|
1991
1755
|
```
|
|
1992
1756
|
|
|
1993
1757
|
Subscribes a wildcard listener that receives all events and returns an unsubscribe function.
|
|
1994
1758
|
|
|
1995
1759
|
### Parameters
|
|
1996
1760
|
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
[`EventAnyListener`](#../type-aliases/EventAnyListener)
|
|
1761
|
+
| Parameter | Type |
|
|
1762
|
+
| ------ | ------ |
|
|
1763
|
+
| `listener` | [`EventAnyListener`](#../type-aliases/EventAnyListener) |
|
|
2000
1764
|
|
|
2001
1765
|
### Returns
|
|
2002
1766
|
|
|
@@ -2007,26 +1771,23 @@ Subscribes a wildcard listener that receives all events and returns an unsubscri
|
|
|
2007
1771
|
### once()
|
|
2008
1772
|
|
|
2009
1773
|
```ts
|
|
2010
|
-
once<TEventName>(eventName, listener): EventUnsubscribeFunction;
|
|
1774
|
+
once<TEventName>(eventName: TEventName, listener: EventListener<T[TEventName]>): EventUnsubscribeFunction;
|
|
2011
1775
|
```
|
|
2012
1776
|
|
|
2013
1777
|
Subscribes a listener that will be invoked only once for the specified event, then automatically removed.
|
|
2014
1778
|
|
|
2015
1779
|
### Type Parameters
|
|
2016
1780
|
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
`TEventName` *extends* `string` \| `number` \| `symbol`
|
|
1781
|
+
| Type Parameter |
|
|
1782
|
+
| ------ |
|
|
1783
|
+
| `TEventName` *extends* `string` \| `number` \| `symbol` |
|
|
2020
1784
|
|
|
2021
1785
|
### Parameters
|
|
2022
1786
|
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
`TEventName`
|
|
2026
|
-
|
|
2027
|
-
#### listener
|
|
2028
|
-
|
|
2029
|
-
[`EventListener`](#../type-aliases/EventListener)\<`T`\[`TEventName`\]\>
|
|
1787
|
+
| Parameter | Type |
|
|
1788
|
+
| ------ | ------ |
|
|
1789
|
+
| `eventName` | `TEventName` |
|
|
1790
|
+
| `listener` | [`EventListener`](#../type-aliases/EventListener)\<`T`\[`TEventName`\]\> |
|
|
2030
1791
|
|
|
2031
1792
|
### Returns
|
|
2032
1793
|
|
|
@@ -2048,9 +1809,9 @@ Parameters type for configuring a BaseEmitter instance.
|
|
|
2048
1809
|
|
|
2049
1810
|
## Type Parameters
|
|
2050
1811
|
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
`T` *extends* `EmptyObject`
|
|
1812
|
+
| Type Parameter | Default type |
|
|
1813
|
+
| ------ | ------ |
|
|
1814
|
+
| `T` *extends* `EmptyObject` | `EmptyObject` |
|
|
2054
1815
|
|
|
2055
1816
|
### <a id="DebugLogger"></a>DebugLogger
|
|
2056
1817
|
|
|
@@ -2059,7 +1820,7 @@ Parameters type for configuring a BaseEmitter instance.
|
|
|
2059
1820
|
***
|
|
2060
1821
|
|
|
2061
1822
|
```ts
|
|
2062
|
-
type DebugLogger = (type, debugName, eventName
|
|
1823
|
+
type DebugLogger = (type: string, debugName: string, eventName?: EventName, eventData?: EventArgs) => void;
|
|
2063
1824
|
```
|
|
2064
1825
|
|
|
2065
1826
|
Emittery can collect and log debug information.
|
|
@@ -2071,21 +1832,12 @@ See API for more information on how debugging works.
|
|
|
2071
1832
|
|
|
2072
1833
|
## Parameters
|
|
2073
1834
|
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
`string`
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
`string`
|
|
2081
|
-
|
|
2082
|
-
### eventName?
|
|
2083
|
-
|
|
2084
|
-
[`EventName`](#EventName)
|
|
2085
|
-
|
|
2086
|
-
### eventData?
|
|
2087
|
-
|
|
2088
|
-
[`EventArgs`](#EventArgs)
|
|
1835
|
+
| Parameter | Type |
|
|
1836
|
+
| ------ | ------ |
|
|
1837
|
+
| `type` | `string` |
|
|
1838
|
+
| `debugName` | `string` |
|
|
1839
|
+
| `eventName?` | [`EventName`](#EventName) |
|
|
1840
|
+
| `eventData?` | [`EventArgs`](#EventArgs) |
|
|
2089
1841
|
|
|
2090
1842
|
## Returns
|
|
2091
1843
|
|
|
@@ -2098,34 +1850,22 @@ See API for more information on how debugging works.
|
|
|
2098
1850
|
***
|
|
2099
1851
|
|
|
2100
1852
|
```ts
|
|
2101
|
-
type DebugOptions =
|
|
1853
|
+
type DebugOptions = {
|
|
1854
|
+
enabled?: boolean;
|
|
1855
|
+
logger?: DebugLogger;
|
|
1856
|
+
name: string;
|
|
1857
|
+
};
|
|
2102
1858
|
```
|
|
2103
1859
|
|
|
2104
1860
|
Configure debug options of an instance.
|
|
2105
1861
|
|
|
2106
1862
|
## Properties
|
|
2107
1863
|
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
***
|
|
2115
|
-
|
|
2116
|
-
### logger?
|
|
2117
|
-
|
|
2118
|
-
```ts
|
|
2119
|
-
optional logger: DebugLogger;
|
|
2120
|
-
```
|
|
2121
|
-
|
|
2122
|
-
***
|
|
2123
|
-
|
|
2124
|
-
### name
|
|
2125
|
-
|
|
2126
|
-
```ts
|
|
2127
|
-
readonly name: string;
|
|
2128
|
-
```
|
|
1864
|
+
| Property | Modifier | Type |
|
|
1865
|
+
| ------ | ------ | ------ |
|
|
1866
|
+
| <a id="enabled"></a> `enabled?` | `public` | `boolean` |
|
|
1867
|
+
| <a id="logger"></a> `logger?` | `public` | [`DebugLogger`](#DebugLogger) |
|
|
1868
|
+
| <a id="name"></a> `name` | `readonly` | `string` |
|
|
2129
1869
|
|
|
2130
1870
|
### <a id="EventAnyListener"></a>EventAnyListener
|
|
2131
1871
|
|
|
@@ -2134,30 +1874,23 @@ readonly name: string;
|
|
|
2134
1874
|
***
|
|
2135
1875
|
|
|
2136
1876
|
```ts
|
|
2137
|
-
type EventAnyListener<TEventArgs> = (eventName, eventData) => Promisable<void>;
|
|
1877
|
+
type EventAnyListener<TEventArgs> = (eventName: EventName, eventData: TEventArgs) => Promisable<void>;
|
|
2138
1878
|
```
|
|
2139
1879
|
|
|
2140
1880
|
A listener that receives all events regardless of name.
|
|
2141
1881
|
|
|
2142
1882
|
## Type Parameters
|
|
2143
1883
|
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
`TEventArgs` *extends* [`EventArgs`](#EventArgs)
|
|
1884
|
+
| Type Parameter | Default type |
|
|
1885
|
+
| ------ | ------ |
|
|
1886
|
+
| `TEventArgs` *extends* [`EventArgs`](#EventArgs) | [`EventArgs`](#EventArgs) |
|
|
2147
1887
|
|
|
2148
1888
|
## Parameters
|
|
2149
1889
|
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
[`EventName`](#EventName)
|
|
2153
|
-
|
|
2154
|
-
The name of the emitted event.
|
|
2155
|
-
|
|
2156
|
-
### eventData
|
|
2157
|
-
|
|
2158
|
-
`TEventArgs`
|
|
2159
|
-
|
|
2160
|
-
The data associated with the event.
|
|
1890
|
+
| Parameter | Type | Description |
|
|
1891
|
+
| ------ | ------ | ------ |
|
|
1892
|
+
| `eventName` | [`EventName`](#EventName) | The name of the emitted event. |
|
|
1893
|
+
| `eventData` | `TEventArgs` | The data associated with the event. |
|
|
2161
1894
|
|
|
2162
1895
|
## Returns
|
|
2163
1896
|
|
|
@@ -2182,7 +1915,9 @@ The allowed types for event argument payloads.
|
|
|
2182
1915
|
***
|
|
2183
1916
|
|
|
2184
1917
|
```ts
|
|
2185
|
-
type EventData =
|
|
1918
|
+
type EventData = {
|
|
1919
|
+
[key: string | number | symbol]: EventArgs;
|
|
1920
|
+
};
|
|
2186
1921
|
```
|
|
2187
1922
|
|
|
2188
1923
|
A mapping of event names to their corresponding event argument types.
|
|
@@ -2200,24 +1935,22 @@ A mapping of event names to their corresponding event argument types.
|
|
|
2200
1935
|
***
|
|
2201
1936
|
|
|
2202
1937
|
```ts
|
|
2203
|
-
type EventListener<TEventArgs> = (eventData) => Promisable<void>;
|
|
1938
|
+
type EventListener<TEventArgs> = (eventData: TEventArgs) => Promisable<void>;
|
|
2204
1939
|
```
|
|
2205
1940
|
|
|
2206
1941
|
A listener for a specific event type.
|
|
2207
1942
|
|
|
2208
1943
|
## Type Parameters
|
|
2209
1944
|
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
`TEventArgs` *extends* [`EventArgs`](#EventArgs)
|
|
1945
|
+
| Type Parameter | Default type |
|
|
1946
|
+
| ------ | ------ |
|
|
1947
|
+
| `TEventArgs` *extends* [`EventArgs`](#EventArgs) | [`EventArgs`](#EventArgs) |
|
|
2213
1948
|
|
|
2214
1949
|
## Parameters
|
|
2215
1950
|
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
`TEventArgs`
|
|
2219
|
-
|
|
2220
|
-
The data associated with the event.
|
|
1951
|
+
| Parameter | Type | Description |
|
|
1952
|
+
| ------ | ------ | ------ |
|
|
1953
|
+
| `eventData` | `TEventArgs` | The data associated with the event. |
|
|
2221
1954
|
|
|
2222
1955
|
## Returns
|
|
2223
1956
|
|
|
@@ -2230,32 +1963,26 @@ The data associated with the event.
|
|
|
2230
1963
|
***
|
|
2231
1964
|
|
|
2232
1965
|
```ts
|
|
2233
|
-
type EventListenerInfo<TEventArgs> =
|
|
1966
|
+
type EventListenerInfo<TEventArgs> = {
|
|
1967
|
+
filter?: TEventArgs;
|
|
1968
|
+
listener: EventListener<TEventArgs>;
|
|
1969
|
+
};
|
|
2234
1970
|
```
|
|
2235
1971
|
|
|
2236
1972
|
Information about a registered event listener, including an optional filter for selective invocation.
|
|
2237
1973
|
|
|
2238
1974
|
## Type Parameters
|
|
2239
1975
|
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
`TEventArgs` *extends* [`EventArgs`](#EventArgs)
|
|
1976
|
+
| Type Parameter | Default type |
|
|
1977
|
+
| ------ | ------ |
|
|
1978
|
+
| `TEventArgs` *extends* [`EventArgs`](#EventArgs) | [`EventArgs`](#EventArgs) |
|
|
2243
1979
|
|
|
2244
1980
|
## Properties
|
|
2245
1981
|
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
```
|
|
2251
|
-
|
|
2252
|
-
***
|
|
2253
|
-
|
|
2254
|
-
### listener
|
|
2255
|
-
|
|
2256
|
-
```ts
|
|
2257
|
-
listener: EventListener<TEventArgs>;
|
|
2258
|
-
```
|
|
1982
|
+
| Property | Type |
|
|
1983
|
+
| ------ | ------ |
|
|
1984
|
+
| <a id="filter"></a> `filter?` | `TEventArgs` |
|
|
1985
|
+
| <a id="listener"></a> `listener` | [`EventListener`](#EventListener)\<`TEventArgs`\> |
|
|
2259
1986
|
|
|
2260
1987
|
### <a id="EventName"></a>EventName
|
|
2261
1988
|
|
|
@@ -2306,60 +2033,38 @@ Parameters for constructing an Events instance, with optional debug configuratio
|
|
|
2306
2033
|
***
|
|
2307
2034
|
|
|
2308
2035
|
```ts
|
|
2309
|
-
type MetaEventData<TEventData> =
|
|
2036
|
+
type MetaEventData<TEventData> = {
|
|
2037
|
+
listenerAdded: {
|
|
2038
|
+
eventName?: keyof TEventData;
|
|
2039
|
+
listener: | EventListener<TEventData[keyof TEventData]>
|
|
2040
|
+
| EventAnyListener<TEventData[keyof TEventData]>;
|
|
2041
|
+
};
|
|
2042
|
+
listenerRemoved: {
|
|
2043
|
+
eventName?: keyof TEventData;
|
|
2044
|
+
listener: | EventListener<TEventData[keyof TEventData]>
|
|
2045
|
+
| EventAnyListener<TEventData[keyof TEventData]>;
|
|
2046
|
+
};
|
|
2047
|
+
};
|
|
2310
2048
|
```
|
|
2311
2049
|
|
|
2312
2050
|
Data shape for internal meta events that fire when listeners are added or removed.
|
|
2313
2051
|
|
|
2314
2052
|
## Type Parameters
|
|
2315
2053
|
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
`TEventData` *extends* [`EventData`](#EventData)
|
|
2054
|
+
| Type Parameter |
|
|
2055
|
+
| ------ |
|
|
2056
|
+
| `TEventData` *extends* [`EventData`](#EventData) |
|
|
2319
2057
|
|
|
2320
2058
|
## Properties
|
|
2321
2059
|
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
listenerAdded
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
```ts
|
|
2331
|
-
optional eventName: keyof TEventData;
|
|
2332
|
-
```
|
|
2333
|
-
|
|
2334
|
-
### listener
|
|
2335
|
-
|
|
2336
|
-
```ts
|
|
2337
|
-
listener:
|
|
2338
|
-
| EventListener<TEventData[keyof TEventData]>
|
|
2339
|
-
| EventAnyListener<TEventData[keyof TEventData]>;
|
|
2340
|
-
```
|
|
2341
|
-
|
|
2342
|
-
***
|
|
2343
|
-
|
|
2344
|
-
### listenerRemoved
|
|
2345
|
-
|
|
2346
|
-
```ts
|
|
2347
|
-
listenerRemoved: object;
|
|
2348
|
-
```
|
|
2349
|
-
|
|
2350
|
-
### eventName?
|
|
2351
|
-
|
|
2352
|
-
```ts
|
|
2353
|
-
optional eventName: keyof TEventData;
|
|
2354
|
-
```
|
|
2355
|
-
|
|
2356
|
-
### listener
|
|
2357
|
-
|
|
2358
|
-
```ts
|
|
2359
|
-
listener:
|
|
2360
|
-
| EventListener<TEventData[keyof TEventData]>
|
|
2361
|
-
| EventAnyListener<TEventData[keyof TEventData]>;
|
|
2362
|
-
```
|
|
2060
|
+
| Property | Type |
|
|
2061
|
+
| ------ | ------ |
|
|
2062
|
+
| <a id="listeneradded"></a> `listenerAdded` | \{ `eventName?`: keyof `TEventData`; `listener`: \| [`EventListener`](#EventListener)\<`TEventData`\[keyof `TEventData`\]\> \| [`EventAnyListener`](#EventAnyListener)\<`TEventData`\[keyof `TEventData`\]\>; \} |
|
|
2063
|
+
| `listenerAdded.eventName?` | keyof `TEventData` |
|
|
2064
|
+
| `listenerAdded.listener` | \| [`EventListener`](#EventListener)\<`TEventData`\[keyof `TEventData`\]\> \| [`EventAnyListener`](#EventAnyListener)\<`TEventData`\[keyof `TEventData`\]\> |
|
|
2065
|
+
| <a id="listenerremoved"></a> `listenerRemoved` | \{ `eventName?`: keyof `TEventData`; `listener`: \| [`EventListener`](#EventListener)\<`TEventData`\[keyof `TEventData`\]\> \| [`EventAnyListener`](#EventAnyListener)\<`TEventData`\[keyof `TEventData`\]\>; \} |
|
|
2066
|
+
| `listenerRemoved.eventName?` | keyof `TEventData` |
|
|
2067
|
+
| `listenerRemoved.listener` | \| [`EventListener`](#EventListener)\<`TEventData`\[keyof `TEventData`\]\> \| [`EventAnyListener`](#EventAnyListener)\<`TEventData`\[keyof `TEventData`\]\> |
|
|
2363
2068
|
|
|
2364
2069
|
|
|
2365
2070
|
Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
|