forked from puppeteer/puppeteer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: migrate away from Node's EventEmitter (puppeteer#5979)
- Loading branch information
1 parent
6e060ce
commit b659969
Showing
30 changed files
with
752 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [EventEmitter](./puppeteer.eventemitter.md) > [addListener](./puppeteer.eventemitter.addlistener.md) | ||
|
||
## EventEmitter.addListener() method | ||
|
||
> Warning: This API is now obsolete. | ||
> | ||
> please use `on` instead. | ||
> | ||
Add an event listener. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
addListener(event: EventType, handler: Handler): EventEmitter; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| event | EventType | | | ||
| handler | Handler | | | ||
|
||
<b>Returns:</b> | ||
|
||
[EventEmitter](./puppeteer.eventemitter.md) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [EventEmitter](./puppeteer.eventemitter.md) > [emit](./puppeteer.eventemitter.emit.md) | ||
|
||
## EventEmitter.emit() method | ||
|
||
Emit an event and call any associated listeners. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
emit(event: EventType, eventData?: any): boolean; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| event | EventType | the event you'd like to emit | | ||
| eventData | any | any data you'd like to emit with the event | | ||
|
||
<b>Returns:</b> | ||
|
||
boolean | ||
|
||
`true` if there are any listeners, `false` if there are not. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [EventEmitter](./puppeteer.eventemitter.md) > [listenerCount](./puppeteer.eventemitter.listenercount.md) | ||
|
||
## EventEmitter.listenerCount() method | ||
|
||
Gets the number of listeners for a given event. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
listenerCount(event: EventType): number; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| event | EventType | the event to get the listener count for | | ||
|
||
<b>Returns:</b> | ||
|
||
number | ||
|
||
the number of listeners bound to the given event | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [EventEmitter](./puppeteer.eventemitter.md) | ||
|
||
## EventEmitter class | ||
|
||
The EventEmitter class that many Puppeteer classes extend. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare class EventEmitter implements CommonEventEmitter | ||
``` | ||
## Remarks | ||
This allows you to listen to events that Puppeteer classes fire and act accordingly. Therefore you'll mostly use [on](./puppeteer.eventemitter.on.md) and [off](./puppeteer.eventemitter.off.md) to bind and unbind to event listeners. | ||
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `EventEmitter` class. | ||
## Methods | ||
| Method | Modifiers | Description | | ||
| --- | --- | --- | | ||
| [addListener(event, handler)](./puppeteer.eventemitter.addlistener.md) | | Add an event listener. | | ||
| [emit(event, eventData)](./puppeteer.eventemitter.emit.md) | | Emit an event and call any associated listeners. | | ||
| [listenerCount(event)](./puppeteer.eventemitter.listenercount.md) | | Gets the number of listeners for a given event. | | ||
| [off(event, handler)](./puppeteer.eventemitter.off.md) | | Remove an event listener from firing. | | ||
| [on(event, handler)](./puppeteer.eventemitter.on.md) | | Bind an event listener to fire when an event occurs. | | ||
| [once(event, handler)](./puppeteer.eventemitter.once.md) | | Like <code>on</code> but the listener will only be fired once and then it will be removed. | | ||
| [removeAllListeners(event)](./puppeteer.eventemitter.removealllisteners.md) | | Removes all listeners. If given an event argument, it will remove only listeners for that event. | | ||
| [removeListener(event, handler)](./puppeteer.eventemitter.removelistener.md) | | Remove an event listener. | | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [EventEmitter](./puppeteer.eventemitter.md) > [off](./puppeteer.eventemitter.off.md) | ||
|
||
## EventEmitter.off() method | ||
|
||
Remove an event listener from firing. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
off(event: EventType, handler: Handler): EventEmitter; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| event | EventType | the event type you'd like to stop listening to. | | ||
| handler | Handler | the function that should be removed. | | ||
|
||
<b>Returns:</b> | ||
|
||
[EventEmitter](./puppeteer.eventemitter.md) | ||
|
||
`this` to enable you to chain calls. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [EventEmitter](./puppeteer.eventemitter.md) > [on](./puppeteer.eventemitter.on.md) | ||
|
||
## EventEmitter.on() method | ||
|
||
Bind an event listener to fire when an event occurs. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
on(event: EventType, handler: Handler): EventEmitter; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| event | EventType | the event type you'd like to listen to. Can be a string or symbol. | | ||
| handler | Handler | the function to be called when the event occurs. | | ||
|
||
<b>Returns:</b> | ||
|
||
[EventEmitter](./puppeteer.eventemitter.md) | ||
|
||
`this` to enable you to chain calls. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [EventEmitter](./puppeteer.eventemitter.md) > [once](./puppeteer.eventemitter.once.md) | ||
|
||
## EventEmitter.once() method | ||
|
||
Like `on` but the listener will only be fired once and then it will be removed. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
once(event: EventType, handler: Handler): EventEmitter; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| event | EventType | the event you'd like to listen to | | ||
| handler | Handler | the handler function to run when the event occurs | | ||
|
||
<b>Returns:</b> | ||
|
||
[EventEmitter](./puppeteer.eventemitter.md) | ||
|
||
`this` to enable you to chain calls. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [EventEmitter](./puppeteer.eventemitter.md) > [removeAllListeners](./puppeteer.eventemitter.removealllisteners.md) | ||
|
||
## EventEmitter.removeAllListeners() method | ||
|
||
Removes all listeners. If given an event argument, it will remove only listeners for that event. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
removeAllListeners(event?: EventType): EventEmitter; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| event | EventType | the event to remove listeners for. | | ||
|
||
<b>Returns:</b> | ||
|
||
[EventEmitter](./puppeteer.eventemitter.md) | ||
|
||
`this` to enable you to chain calls. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [EventEmitter](./puppeteer.eventemitter.md) > [removeListener](./puppeteer.eventemitter.removelistener.md) | ||
|
||
## EventEmitter.removeListener() method | ||
|
||
> Warning: This API is now obsolete. | ||
> | ||
> please use `off` instead. | ||
> | ||
Remove an event listener. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
removeListener(event: EventType, handler: Handler): EventEmitter; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| event | EventType | | | ||
| handler | Handler | | | ||
|
||
<b>Returns:</b> | ||
|
||
[EventEmitter](./puppeteer.eventemitter.md) | ||
|
Oops, something went wrong.