"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var UserModel = /** @class */ (function () { function UserModel() { /** * @type {Observer[]} List of subscribers. In real life, the list of * subscribers can be stored more comprehensively (categorized by event * type, etc.). */ this.observers = []; this.state = 0; } /** * The subscription management methods. */ UserModel.prototype.attach = function (observer) { console.log('Subject: Attached an observer.'); this.observers.push(observer); }; UserModel.prototype.detach = function (observer) { var observerIndex = this.observers.indexOf(observer); this.observers.splice(observerIndex, 1); console.log('Subject: Detached an observer.'); }; /** * Trigger an update in each subscriber. */ UserModel.prototype.notify = function () { console.log('Subject: Notifying observers...'); for (var _i = 0, _a = this.observers; _i < _a.length; _i++) { var observer = _a[_i]; observer.update(this.state); } }; UserModel.prototype.someBusinessMethod = function () { console.log("Subject: My state has just changed to: " + this.state); this.notify(); }; return UserModel; }()); exports.UserModel = UserModel;