@sneko/ionic-appauth
Version:
Intergration for OpenId/AppAuth-JS into Ionic V3/4/5
42 lines (41 loc) • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthSubject = void 0;
var tslib_1 = require("tslib");
var AuthSubject = /** @class */ (function () {
function AuthSubject() {
this.observers = [];
}
AuthSubject.prototype.attach = function (observer) {
var observerIndex = this.observers.indexOf(observer);
if (observerIndex !== -1) {
return console.log('Subject: Observer has been attached already.');
}
this.observers.push(observer);
};
AuthSubject.prototype.detach = function (observer) {
var observerIndex = this.observers.indexOf(observer);
if (observerIndex === -1) {
return console.log('Subject: Nonexistent observer.');
}
this.observers.splice(observerIndex, 1);
};
AuthSubject.prototype.notify = function (action) {
var e_1, _a;
try {
for (var _b = tslib_1.__values(this.observers), _c = _b.next(); !_c.done; _c = _b.next()) {
var observer = _c.value;
observer.update(action);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
};
return AuthSubject;
}());
exports.AuthSubject = AuthSubject;