singletons that are retroactively turned into EventEmitters should call the EventEmitter ctor

This commit is contained in:
Charles Kerr 2017-11-01 23:05:27 -05:00
parent 577012370e
commit 1c09dede1a
7 changed files with 14 additions and 0 deletions

View file

@ -10,7 +10,9 @@ const electron = require('electron')
const {deprecate, Menu} = electron
const {EventEmitter} = require('events')
// App is an EventEmitter.
Object.setPrototypeOf(App.prototype, EventEmitter.prototype)
EventEmitter.call(app)
Object.assign(app, {
setApplicationMenu (menu) {

View file

@ -1,6 +1,8 @@
const EventEmitter = require('events').EventEmitter
const {autoUpdater, AutoUpdater} = process.atomBinding('auto_updater')
// AutoUpdater is an EventEmitter.
Object.setPrototypeOf(AutoUpdater.prototype, EventEmitter.prototype)
EventEmitter.call(autoUpdater)
module.exports = autoUpdater

View file

@ -9,7 +9,10 @@ const {Session} = process.atomBinding('session')
const {net, Net} = process.atomBinding('net')
const {URLRequest} = net
// Net is an EventEmitter.
Object.setPrototypeOf(Net.prototype, EventEmitter.prototype)
EventEmitter.call(net)
Object.setPrototypeOf(URLRequest.prototype, EventEmitter.prototype)
const kSupportedProtocols = new Set(['http:', 'https:'])

View file

@ -1,6 +1,8 @@
const {EventEmitter} = require('events')
const {powerMonitor, PowerMonitor} = process.atomBinding('power_monitor')
// PowerMonitor is an EventEmitter.
Object.setPrototypeOf(PowerMonitor.prototype, EventEmitter.prototype)
EventEmitter.call(powerMonitor)
module.exports = powerMonitor

View file

@ -1,6 +1,8 @@
const {EventEmitter} = require('events')
const {screen, Screen} = process.atomBinding('screen')
// Screen is an EventEmitter.
Object.setPrototypeOf(Screen.prototype, EventEmitter.prototype)
EventEmitter.call(screen)
module.exports = screen

View file

@ -1,6 +1,8 @@
const {EventEmitter} = require('events')
const {systemPreferences, SystemPreferences} = process.atomBinding('system_preferences')
// SystemPreferences is an EventEmitter.
Object.setPrototypeOf(SystemPreferences.prototype, EventEmitter.prototype)
EventEmitter.call(systemPreferences)
module.exports = systemPreferences

View file

@ -5,6 +5,7 @@ const {webFrame, WebFrame} = process.atomBinding('web_frame')
// WebFrame is an EventEmitter.
Object.setPrototypeOf(WebFrame.prototype, EventEmitter.prototype)
EventEmitter.call(webFrame)
// Lots of webview would subscribe to webFrame's events.
webFrame.setMaxListeners(0)