import { AppObjectPM, getSingletonComponent, } from "@vived/core";
import { StoredView } from "../Entities";
export class HasStoredViewPM extends AppObjectPM {
}
HasStoredViewPM.type = "HasStoredViewPM";
HasStoredViewPM.get = (appObjects) => getSingletonComponent(HasStoredViewPM.type, appObjects);
export function makeHasStoredViewPM(appObject) {
    return new HasStoredViewPMImp(appObject);
}
class HasStoredViewPMImp extends HasStoredViewPM {
    get storedView() {
        return this.getCachedSingleton(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