Set prototype of constructor directly

This commit is contained in:
Cheng Zhao 2016-08-02 20:38:35 +09:00
parent 8c3232dc56
commit 844f32aa36
19 changed files with 84 additions and 158 deletions

View file

@ -1,6 +1,6 @@
const {EventEmitter} = require('events')
const {app} = require('electron')
const {fromPartition, _setWrapSession} = process.atomBinding('session')
const {fromPartition, Session} = process.atomBinding('session')
// Public API.
Object.defineProperties(exports, {
@ -14,9 +14,8 @@ Object.defineProperties(exports, {
}
})
// Wraps native Session class.
_setWrapSession(function (session) {
// Session is an EventEmitter.
Object.setPrototypeOf(session.__proto__, EventEmitter.prototype)
app.emit('session-created', session)
})
Object.setPrototypeOf(Session.prototype, EventEmitter.prototype)
Session.prototype._init = function () {
app.emit('session-created', this)
}