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:
@ -2,7 +2,7 @@
|
||||
/* exported Indicator */
|
||||
|
||||
const { Clutter, Gio, GLib, GObject, Gvc, St } = imports.gi;
|
||||
const Signals = imports.signals;
|
||||
const Signals = imports.misc.signals;
|
||||
|
||||
const Main = imports.ui.main;
|
||||
const PanelMenu = imports.ui.panelMenu;
|
||||
@ -29,8 +29,10 @@ function getMixerControl() {
|
||||
return _mixerControl;
|
||||
}
|
||||
|
||||
var StreamSlider = class {
|
||||
var StreamSlider = class extends Signals.EventEmitter {
|
||||
constructor(control) {
|
||||
super();
|
||||
|
||||
this._control = control;
|
||||
|
||||
this.item = new PopupMenu.PopupBaseMenuItem({ activate: false });
|
||||
@ -213,7 +215,6 @@ var StreamSlider = class {
|
||||
return maxVolume / this._control.get_vol_max_norm();
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(StreamSlider.prototype);
|
||||
|
||||
var OutputStreamSlider = class extends StreamSlider {
|
||||
constructor(control) {
|
||||
|
Reference in New Issue
Block a user