a88e59c1a8
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>
23 lines
541 B
JavaScript
23 lines
541 B
JavaScript
const Signals = imports.signals;
|
|
const SignalTracker = imports.misc.signalTracker;
|
|
|
|
var EventEmitter = class EventEmitter {
|
|
connectObject(...args) {
|
|
return SignalTracker.connectObject(this, ...args);
|
|
}
|
|
|
|
disconnectObject(...args) {
|
|
return SignalTracker.disconnectObject(this, ...args);
|
|
}
|
|
|
|
connect_object(...args) {
|
|
return this.connectObject(...args);
|
|
}
|
|
|
|
disconnect_object(...args) {
|
|
return this.disconnectObject(...args);
|
|
}
|
|
};
|
|
|
|
Signals.addSignalMethods(EventEmitter.prototype);
|