import { useCallback, useEffect } from "react";
import { canvasEventBus } from "../utils/CanvasEventBus.js";
function useCanvasEvent(eventName, callback) {
    useEffect(()=>canvasEventBus.on(eventName, callback), [
        eventName,
        callback
    ]);
}
function useCanvasEvents() {
    const emit = useCallback((eventName, payload)=>{
        canvasEventBus.emit(eventName, payload);
    }, []);
    const subscribe = useCallback((eventName, callback)=>canvasEventBus.on(eventName, callback), []);
    return {
        emit,
        subscribe,
        eventBus: canvasEventBus
    };
}
export { useCanvasEvent, useCanvasEvents };
