mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
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:
parent
9e30afe678
commit
a88e59c1a8
39 changed files with 204 additions and 169 deletions
|
|
@ -1,7 +1,8 @@
|
|||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
/* exported WeatherClient */
|
||||
|
||||
const { Geoclue, Gio, GLib, GWeather, Shell } = imports.gi;
|
||||
const Signals = imports.signals;
|
||||
const Signals = imports.misc.signals;
|
||||
|
||||
const PermissionStore = imports.misc.permissionStore;
|
||||
|
||||
|
|
@ -20,8 +21,10 @@ const WEATHER_APP_ID = 'org.gnome.Weather.desktop';
|
|||
// Minimum time between updates to show loading indication
|
||||
var UPDATE_THRESHOLD = 10 * GLib.TIME_SPAN_MINUTE;
|
||||
|
||||
var WeatherClient = class {
|
||||
var WeatherClient = class extends Signals.EventEmitter {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this._loading = false;
|
||||
this._locationValid = false;
|
||||
this._lastUpdate = GLib.DateTime.new_from_unix_local(0);
|
||||
|
|
@ -319,4 +322,3 @@ var WeatherClient = class {
|
|||
this._updateAutoLocation();
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(WeatherClient.prototype);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue