mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-14 12:58:39 -09:00
Server now extends EventEmitter instead of creating and EventEmitter instance (#406)
This commit is contained in:
parent
7e889dd509
commit
5764b31e26
1 changed files with 3 additions and 19 deletions
22
app/rpc.js
22
app/rpc.js
|
|
@ -2,12 +2,12 @@ const { EventEmitter } = require('events');
|
|||
const { ipcMain } = require('electron');
|
||||
const uuid = require('uuid');
|
||||
|
||||
class Server {
|
||||
class Server extends EventEmitter {
|
||||
|
||||
constructor (win) {
|
||||
super();
|
||||
this.win = win;
|
||||
this.ipcListener = this.ipcListener.bind(this);
|
||||
this.emitter = new EventEmitter();
|
||||
|
||||
if (this.destroyed) return;
|
||||
|
||||
|
|
@ -29,29 +29,13 @@ class Server {
|
|||
}
|
||||
|
||||
ipcListener (event, { ev, data }) {
|
||||
this.emitter.emit(ev, data);
|
||||
super.emit(ev, data);
|
||||
}
|
||||
|
||||
emit (ch, data) {
|
||||
this.wc.send(this.id, { ch, data });
|
||||
}
|
||||
|
||||
on (ev, fn) {
|
||||
this.emitter.on(ev, fn);
|
||||
}
|
||||
|
||||
once (ev, fn) {
|
||||
this.emitter.once(ev, fn);
|
||||
}
|
||||
|
||||
removeListener (ev, fn) {
|
||||
this.emitter.removeListener(ev, fn);
|
||||
}
|
||||
|
||||
removeAllListeners () {
|
||||
this.emitter.removeAllListeners();
|
||||
}
|
||||
|
||||
destroy () {
|
||||
this.removeAllListeners();
|
||||
this.wc.removeAllListeners();
|
||||
|
|
|
|||
Loading…
Reference in a new issue