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:
@ -4,7 +4,7 @@
|
||||
const {
|
||||
Clutter, Cogl, Gio, GLib, GObject, Graphene, Meta, Pango, Shell, St,
|
||||
} = imports.gi;
|
||||
const Signals = imports.signals;
|
||||
const Signals = imports.misc.signals;
|
||||
const System = imports.system;
|
||||
|
||||
const History = imports.misc.history;
|
||||
@ -56,8 +56,10 @@ function _getAutoCompleteGlobalKeywords() {
|
||||
return keywords.concat(windowProperties).concat(headerProperties);
|
||||
}
|
||||
|
||||
var AutoComplete = class AutoComplete {
|
||||
var AutoComplete = class AutoComplete extends Signals.EventEmitter {
|
||||
constructor(entry) {
|
||||
super();
|
||||
|
||||
this._entry = entry;
|
||||
this._entry.connect('key-press-event', this._entryKeyPressEvent.bind(this));
|
||||
this._lastTabTime = global.get_current_time();
|
||||
@ -121,7 +123,6 @@ var AutoComplete = class AutoComplete {
|
||||
this._entry.clutter_text.insert_text(additionalCompletionText, cursorPos);
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(AutoComplete.prototype);
|
||||
|
||||
|
||||
var Notebook = GObject.registerClass({
|
||||
|
Reference in New Issue
Block a user