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 addDragMonitor, removeDragMonitor, makeDraggable */
|
||||
|
||||
const { Clutter, GLib, Meta, Shell, St } = imports.gi;
|
||||
const Signals = imports.signals;
|
||||
const Signals = imports.misc.signals;
|
||||
|
||||
const Main = imports.ui.main;
|
||||
const Params = imports.misc.params;
|
||||
@ -78,8 +78,10 @@ function removeDragMonitor(monitor) {
|
||||
}
|
||||
}
|
||||
|
||||
var _Draggable = class _Draggable {
|
||||
var _Draggable = class _Draggable extends Signals.EventEmitter {
|
||||
constructor(actor, params) {
|
||||
super();
|
||||
|
||||
params = Params.parse(params, {
|
||||
manualMode: false,
|
||||
timeoutThreshold: 0,
|
||||
@ -801,7 +803,6 @@ var _Draggable = class _Draggable {
|
||||
currentDraggable = null;
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(_Draggable.prototype);
|
||||
|
||||
/**
|
||||
* makeDraggable:
|
||||
|
Reference in New Issue
Block a user