Skip to content

Commit

Permalink
chore: bind this to event handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning00Blade committed Apr 19, 2024
1 parent 492a962 commit eeed3a7
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/puppeteer-core/src/cdp/NetworkManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,21 @@ export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
#userAgentMetadata?: Protocol.Emulation.UserAgentMetadata;

readonly #handlers = [
['Fetch.requestPaused', this.#onRequestPaused],
['Fetch.authRequired', this.#onAuthRequired],
['Network.requestWillBeSent', this.#onRequestWillBeSent],
['Network.requestServedFromCache', this.#onRequestServedFromCache],
['Network.responseReceived', this.#onResponseReceived],
['Network.loadingFinished', this.#onLoadingFinished],
['Network.loadingFailed', this.#onLoadingFailed],
['Network.responseReceivedExtraInfo', this.#onResponseReceivedExtraInfo],
[CDPSessionEvent.Disconnected, this.#removeClient],
['Fetch.requestPaused', this.#onRequestPaused.bind(this)],
['Fetch.authRequired', this.#onAuthRequired.bind(this)],
['Network.requestWillBeSent', this.#onRequestWillBeSent.bind(this)],
[
'Network.requestServedFromCache',
this.#onRequestServedFromCache.bind(this),
],
['Network.responseReceived', this.#onResponseReceived.bind(this)],
['Network.loadingFinished', this.#onLoadingFinished.bind(this)],
['Network.loadingFailed', this.#onLoadingFailed.bind(this)],
[
'Network.responseReceivedExtraInfo',
this.#onResponseReceivedExtraInfo.bind(this),
],
[CDPSessionEvent.Disconnected, this.#removeClient.bind(this)],
] as const;

#clients = new Map<CDPSession, DisposableStack>();
Expand Down

0 comments on commit eeed3a7

Please sign in to comment.