import { AppObjectEntity, getSingletonComponent } from "@vived/core";
export class AppDispatcher extends AppObjectEntity {
}
AppDispatcher.type = "APP_DISPATCHER";
AppDispatcher.get = (appObjects) => getSingletonComponent(AppDispatcher.type, appObjects);
export function makeAppDispatcher(appObject, hostHandler) {
    return new AppDispatcherImp(appObject, hostHandler);
}
class AppDispatcherImp extends AppDispatcher {
    constructor(appObject, hostHandler) {
        super(appObject, AppDispatcher.type);
        this.hostHandler = hostHandler;
        this.dispatch = (request) => {
            this.hostHandler(request);
        };
        this.formRequestAndDispatch = (type, version, payload) => {
            const request = {
                type,
                version,
                payload,
            };
            this.hostHandler(request);
        };
    }
}
//# sourceMappingURL=AppDispatcher.js.map