mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
refactor: consolidate all events in Events.js (#3772)
This will allow us to break all dependency cycles that were forcing us to put many things in a single file (e.g. ExecutionContext and ElementHandle).
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
const {helper, assert} = require('./helper');
|
||||
const {Events} = require('./Events');
|
||||
const debugProtocol = require('debug')('puppeteer:protocol');
|
||||
const debugSession = require('debug')('puppeteer:session');
|
||||
const EventEmitter = require('events');
|
||||
@@ -120,7 +121,7 @@ class Connection extends EventEmitter {
|
||||
for (const session of this._sessions.values())
|
||||
session._onClosed();
|
||||
this._sessions.clear();
|
||||
this.emit(Connection.Events.Disconnected);
|
||||
this.emit(Events.Connection.Disconnected);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
@@ -140,10 +141,6 @@ class Connection extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
Connection.Events = {
|
||||
Disconnected: Symbol('Connection.Events.Disconnected'),
|
||||
};
|
||||
|
||||
class CDPSession extends EventEmitter {
|
||||
/**
|
||||
* @param {!Connection|!CDPSession} connection
|
||||
@@ -228,7 +225,7 @@ class CDPSession extends EventEmitter {
|
||||
callback.reject(rewriteError(callback.error, `Protocol error (${callback.method}): Target closed.`));
|
||||
this._callbacks.clear();
|
||||
this._connection = null;
|
||||
this.emit(CDPSession.Events.Disconnected);
|
||||
this.emit(Events.CDPSession.Disconnected);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,10 +239,6 @@ class CDPSession extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
CDPSession.Events = {
|
||||
Disconnected: Symbol('CDPSession.Events.Disconnected'),
|
||||
};
|
||||
|
||||
helper.tracePublicAPI(CDPSession);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user