"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppDispatcher = void 0;
exports.makeAppDispatcher = makeAppDispatcher;
const core_1 = require("@vived/core");
class AppDispatcher extends core_1.AppObjectEntity {
}
exports.AppDispatcher = AppDispatcher;
AppDispatcher.type = "APP_DISPATCHER";
AppDispatcher.get = (appObjects) => (0, core_1.getSingletonComponent)(AppDispatcher.type, appObjects);
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