"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useMainwrapV4EventBus = useMainwrapV4EventBus;
const react_1 = require("react");
const eventBus_1 = require("../utils/eventBus");
function useMainwrapV4EventBus(eventName, handler) {
    const handlerRef = (0, react_1.useRef)(handler);
    (0, react_1.useEffect)(() => {
        handlerRef.current = handler;
    }, [handler]);
    (0, react_1.useEffect)(() => {
        const listener = (payload) => handlerRef.current(payload);
        eventBus_1.eventBus.on(eventName, listener);
        return () => eventBus_1.eventBus.off(eventName, listener);
    }, [eventName]);
}
//# sourceMappingURL=use-event-bus.js.map