"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HasStoredViewPM = void 0;
exports.makeHasStoredViewPM = makeHasStoredViewPM;
const core_1 = require("@vived/core");
const Entities_1 = require("../Entities");
class HasStoredViewPM extends core_1.AppObjectPM {
}
exports.HasStoredViewPM = HasStoredViewPM;
HasStoredViewPM.type = "HasStoredViewPM";
HasStoredViewPM.get = (appObjects) => (0, core_1.getSingletonComponent)(HasStoredViewPM.type, appObjects);
function makeHasStoredViewPM(appObject) {
    return new HasStoredViewPMImp(appObject);
}
class HasStoredViewPMImp extends HasStoredViewPM {
    get storedView() {
        return this.getCachedSingleton(Entities_1.StoredView.type);
    }
    vmsAreEqual(a, b) {
        return a === b;
    }
    constructor(appObject) {
        super(appObject, HasStoredViewPM.type);
        this.onRepoChange = () => {
            if (!this.storedView)
                return;
            this.doUpdateView(this.storedView.hasStoredView);
        };
        this.dispose = () => {
            super.dispose();
            this.storedView?.removeChangeObserver(this.onRepoChange);
            this.storedView?.removeOnDisposeObserver(this.dispose);
        };
        this.storedView?.addChangeObserver(this.onRepoChange);
        this.onRepoChange();
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=HasStoredViewPM.js.map