import { AppObjectUC } from "@vived/core";
import { AppHandlerEntity, UnsupportedRequestVersion, } from "../Entities";
export class DisposeAppBaseUC extends AppObjectUC {
    constructor() {
        super(...arguments);
        this.requestType = "DISPOSE_APP";
        this.payloadVersion = 1;
    }
}
DisposeAppBaseUC.type = "DisposeAppBaseUC";
export function makeDisposeAppUC(appObject) {
    return new DisposeAppBaseUCImp(appObject);
}
class DisposeAppBaseUCImp extends DisposeAppBaseUC {
    constructor(appObject) {
        super(appObject, DisposeAppBaseUC.type);
        this.action = () => {
            // inject if needed
        };
        this.handleRequest = (version) => {
            if (version === this.payloadVersion) {
                this.action();
            }
            else {
                throw new UnsupportedRequestVersion(this.requestType, version);
            }
        };
        const handler = appObject.getComponent(AppHandlerEntity.type);
        if (!handler) {
            this.warn("DisposeAppBaseUC has been added to an app object that does not have an AppHandlerEntity. Add one first");
            return;
        }
        handler.registerRequestHandler(this);
    }
}
//# sourceMappingURL=DisposeAppUC.js.map