implement wrapSession
This commit is contained in:
parent
aed487ef40
commit
4062ca5f68
5 changed files with 71 additions and 43 deletions
|
@ -1,10 +1,15 @@
|
|||
EventEmitter = require('events').EventEmitter
|
||||
|
||||
bindings = process.atomBinding 'app'
|
||||
sessionBindings = process.atomBinding 'session'
|
||||
|
||||
app = bindings.app
|
||||
app.__proto__ = EventEmitter.prototype
|
||||
|
||||
wrapSession = (session) ->
|
||||
# session is an Event Emitter.
|
||||
session.__proto__ = EventEmitter.prototype
|
||||
|
||||
app.setApplicationMenu = (menu) ->
|
||||
require('menu').setApplicationMenu menu
|
||||
|
||||
|
@ -32,10 +37,8 @@ app.setAppPath = (path) ->
|
|||
app.getAppPath = ->
|
||||
appPath
|
||||
|
||||
app.once 'ready', ->
|
||||
app.defaultSession.__proto__ = EventEmitter.prototype
|
||||
# Be compatible with old API.
|
||||
@emit 'finish-launching'
|
||||
# Be compatible with old API.
|
||||
app.once 'ready', -> @emit 'finish-launching'
|
||||
app.terminate = app.quit
|
||||
app.exit = process.exit
|
||||
app.getHomeDir = -> @getPath 'home'
|
||||
|
@ -43,5 +46,9 @@ app.getDataPath = -> @getPath 'userData'
|
|||
app.setDataPath = (path) -> @setPath 'userData', path
|
||||
app.resolveProxy = -> @defaultSession.resolveProxy.apply @defaultSession, arguments
|
||||
|
||||
# Session wrapper.
|
||||
sessionBindings._setWrapSession wrapSession
|
||||
process.once 'exit', sessionBindings._clearWrapSession
|
||||
|
||||
# Only one App object pemitted.
|
||||
module.exports = app
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue