import { AppObjectUC, getSingletonComponent, } from "@vived/core";
import { AppDispatcher } from "../Entities/AppDispatcher";
export class GoToNextStateUC extends AppObjectUC {
    constructor() {
        super(...arguments);
        this.requestType = "GO_TO_NEXT_STATE";
    }
}
GoToNextStateUC.type = "GoToNextStateUC";
GoToNextStateUC.get = (appObjects) => getSingletonComponent(GoToNextStateUC.type, appObjects);
export function makeGoToNextStateUC(appObject) {
    return new DispatchStateChangeUCImp(appObject);
}
class DispatchStateChangeUCImp extends GoToNextStateUC {
    constructor(appObject) {
        super(appObject, GoToNextStateUC.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("GoToNextStateUC has been added to an App Object that does not have a AppDispatcher. Add a dispatcher first");
            this.dispose();
        }
    }
}
//# sourceMappingURL=GoToNextStateUC.js.map