import { AppObjectUC, getSingletonComponent, } from "@vived/core";
import { AppDispatcher } from "../Entities/AppDispatcher";
export class AppIsReadyUC extends AppObjectUC {
    constructor() {
        super(...arguments);
        this.requestType = "APP_IS_READY";
    }
}
AppIsReadyUC.type = "AppIsReadyUC";
AppIsReadyUC.get = (appObjects) => getSingletonComponent(AppIsReadyUC.type, appObjects);
export function makeAppIsReadyUC(appObject) {
    return new AppIsReadyUCImp(appObject);
}
export function appIsReady(appObjects) {
    const dispatchUC = AppIsReadyUC.get(appObjects);
    if (dispatchUC) {
        dispatchUC.doDispatch();
    }
    else {
        appObjects.submitWarning("appIsReady", "Can't find AppIsReadyUC");
    }
}
class AppIsReadyUCImp extends AppIsReadyUC {
    constructor(appObject) {
        super(appObject, AppIsReadyUC.type);
        this.requestVersion = 1;
        this.doDispatch = () => {
            if (!this.appDispatcher)
                return;
            this.appDispatcher.formRequestAndDispatch(this.requestType, this.requestVersion);
        };
        this.appDispatcher = appObject.getComponent(AppDispatcher.type);
        if (!this.appDispatcher) {
            this.warn("AppIsReadyUCImp has been added to an App Object that does not have a AppDispatcher. Add a dispatcher first");
            this.dispose();
        }
    }
}
//# sourceMappingURL=AppIsReadyUC.js.map