Skip to content

Commit

Permalink
Merge pull request #10995 from electron/initialize-retroactive-event-…
Browse files Browse the repository at this point in the history
…emitters

singletons that are retroactively turned into EventEmitters should ca…
  • Loading branch information
codebytere authored Nov 3, 2017
2 parents c3930f2 + 1c09ded commit 41fa61b
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/browser/api/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/auto-updater/auto-updater-native.js
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions lib/browser/api/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:'])
Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/power-monitor.js
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions lib/browser/api/screen.js
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions lib/browser/api/system-preferences.js
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions lib/renderer/api/web-frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 41fa61b

Please sign in to comment.