Unverified Commit e36240f3 authored by Guilherme Gazzo's avatar Guilherme Gazzo Committed by GitHub

fix: Emitter: Created events method (#311)

parent d60524b4
......@@ -39,6 +39,7 @@ yarn add @rocket.chat/emitter
- [Handler](#handler)
- [IEmitter](#iemitter)
- [Emitter](#emitter)
- [events](#events)
- [has](#has)
- [Parameters](#parameters)
- [on](#on)
......@@ -64,6 +65,12 @@ Type: function (event: T): void
The event emitter class.
#### events
Returns the whole EventType list
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[EventType](#eventtype)>**
#### has
Returns `true` if this emmiter has a listener attached to the `key` event type
......
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@rocket.chat/emitter](./emitter.md) &gt; [Emitter](./emitter.emitter.md) &gt; [events](./emitter.emitter.events.md)
## Emitter.events() method
Returns the whole EventType list
<b>Signature:</b>
```typescript
events(): EventType[];
```
<b>Returns:</b>
[EventType](./emitter.eventtype.md)<!-- -->\[\]
......@@ -18,6 +18,7 @@ export declare class Emitter implements IEmitter
| Method | Modifiers | Description |
| --- | --- | --- |
| [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. |
| [events()](./emitter.emitter.events.md) | | Returns the whole EventType list |
| [has(key)](./emitter.emitter.has.md) | | Returns <code>true</code> if this emmiter has a listener attached to the <code>key</code> event type |
| [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 |
| [on(type, handler)](./emitter.emitter.on.md) | | Adds the <code>handler</code> function to listen events of the <code>type</code> type. |
......
......@@ -36,6 +36,13 @@ export class Emitter implements IEmitter {
private [once] = new WeakMap<Handler, number>();
/**
* Returns the whole EventType list
*/
events() : EventType[] {
return Array.from(this[evts].keys());
}
/**
* Returns `true` if this emmiter has a listener attached to the `key` event type
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment