Adopt EventEmitter class instead of injecting Signal methods
Introduce a new class, EventEmitter, which implements signal handling for pure JavaScript classes. EventEmitter still utilizes GJS' addSignalMethods internally. EventEmitter allows static typechecking to understand the structure of event-emitting JS classes and makes creating child classes simpler. The name 'EventEmitter' mirrors a common name for this pattern in Node and in JS libraries. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2043>
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
/* exported Manager */
|
||||
|
||||
const Gio = imports.gi.Gio;
|
||||
const Signals = imports.signals;
|
||||
const Signals = imports.misc.signals;
|
||||
|
||||
const { loadInterfaceXML } = imports.misc.fileUtils;
|
||||
|
||||
@ -14,8 +15,10 @@ const Service = Gio.DBusProxy.makeProxyWrapper(ServiceIface);
|
||||
const RealmIface = loadInterfaceXML("org.freedesktop.realmd.Realm");
|
||||
const Realm = Gio.DBusProxy.makeProxyWrapper(RealmIface);
|
||||
|
||||
var Manager = class {
|
||||
var Manager = class extends Signals.EventEmitter {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this._aggregateProvider = Provider(Gio.DBus.system,
|
||||
'org.freedesktop.realmd',
|
||||
'/org/freedesktop/realmd',
|
||||
@ -105,4 +108,3 @@ var Manager = class {
|
||||
this._updateLoginFormat();
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(Manager.prototype);
|
||||
|
Reference in New Issue
Block a user