Skip to content

Commit e36240f

Browse files
authored
fix: Emitter: Created events method (#311)
1 parent d60524b commit e36240f

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

packages/emitter/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ yarn add @rocket.chat/emitter
3939
- [Handler](#handler)
4040
- [IEmitter](#iemitter)
4141
- [Emitter](#emitter)
42+
- [events](#events)
4243
- [has](#has)
4344
- [Parameters](#parameters)
4445
- [on](#on)
@@ -64,6 +65,12 @@ Type: function (event: T): void
6465

6566
The event emitter class.
6667

68+
#### events
69+
70+
Returns the whole EventType list
71+
72+
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[EventType](#eventtype)>**
73+
6774
#### has
6875

6976
Returns `true` if this emmiter has a listener attached to the `key` event type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@rocket.chat/emitter](./emitter.md) &gt; [Emitter](./emitter.emitter.md) &gt; [events](./emitter.emitter.events.md)
4+
5+
## Emitter.events() method
6+
7+
Returns the whole EventType list
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
events(): EventType[];
13+
```
14+
<b>Returns:</b>
15+
16+
[EventType](./emitter.eventtype.md)<!-- -->\[\]
17+

packages/emitter/docs/emitter.emitter.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export declare class Emitter implements IEmitter
1818
| Method | Modifiers | Description |
1919
| --- | --- | --- |
2020
| [emit(type, e)](./emitter.emitter.emit.md) | | Calls each of the handlers registered for the event of <code>type</code> type, in the order they were registered, passing the supplied argument <code>e</code> to each. |
21+
| [events()](./emitter.emitter.events.md) | | Returns the whole EventType list |
2122
| [has(key)](./emitter.emitter.has.md) | | Returns <code>true</code> if this emmiter has a listener attached to the <code>key</code> event type |
2223
| [off(type, handler)](./emitter.emitter.off.md) | | Removes the specified <code>handler</code> from the list of handlers of the event of the <code>type</code> type |
2324
| [on(type, handler)](./emitter.emitter.on.md) | | Adds the <code>handler</code> function to listen events of the <code>type</code> type. |

packages/emitter/src/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ export class Emitter implements IEmitter {
3636

3737
private [once] = new WeakMap<Handler, number>();
3838

39+
/**
40+
* Returns the whole EventType list
41+
*/
42+
events() : EventType[] {
43+
return Array.from(this[evts].keys());
44+
}
45+
3946
/**
4047
* Returns `true` if this emmiter has a listener attached to the `key` event type
4148
*/

0 commit comments

Comments
 (0)