puppeteer/docs/api/puppeteer.eventemitter.md
dependabot[bot] 93e9acc410
chore(deps-dev): Bump the dev-dependencies group with 3 updates (#12101)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nikolay Vitkov <nvitkov@chromium.org>
2024-03-20 15:03:14 +00:00

1.9 KiB

sidebar_label
EventEmitter

EventEmitter class

The EventEmitter class that many Puppeteer classes extend.

Signature:

export declare class EventEmitter<Events extends Record<EventType, unknown>> implements CommonEventEmitter<EventsWithWildcard<Events>>

Implements: CommonEventEmitter<EventsWithWildcard<Events>>

Remarks

This allows you to listen to events that Puppeteer classes fire and act accordingly. Therefore you'll mostly use on and off 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

emit(type, event)

Emit an event and call any associated listeners.

listenerCount(type)

Gets the number of listeners for a given event.

off(type, handler)

Remove an event listener from firing.

on(type, handler)

Bind an event listener to fire when an event occurs.

once(type, handler)

Like on but the listener will only be fired once and then it will be removed.

removeAllListeners(type)

Removes all listeners. If given an event argument, it will remove only listeners for that event.