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>
29 lines
618 B
JavaScript
29 lines
618 B
JavaScript
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
/* exported CredentialManager */
|
|
|
|
const Signals = imports.misc.signals;
|
|
|
|
var CredentialManager = class CredentialManager extends Signals.EventEmitter {
|
|
constructor(service) {
|
|
super();
|
|
|
|
this._token = null;
|
|
this._service = service;
|
|
this._authenticatedSignalId = null;
|
|
}
|
|
|
|
get token() {
|
|
return this._token;
|
|
}
|
|
|
|
set token(t) {
|
|
this._token = t;
|
|
if (this._token)
|
|
this.emit('user-authenticated', this._token);
|
|
}
|
|
|
|
get service() {
|
|
return this._service;
|
|
}
|
|
};
|