useEventEmitter
functionsignature
useEventEmitter(storeId): { emit: (channel: string, type: string, payload: unknown) => void }Emits events to a store from the extension.
Parameters
| Name | Type | Description |
|---|---|---|
storeId | null | string | The store ID to emit events to, or null to disable. |
Returns
{ emit: (channel: string, type: string, payload: unknown) => void }, An object containing the emit(channel, type, payload) function.
Example
example
import { useEventEmitter } from "@yoltra/devtools-ui";
function EmitForm({ storeId }: { storeId: string }) {
const { emit } = useEventEmitter(storeId);
const handleClick = () => {
emit("counter", "INCREMENT", { amount: 1 });
};
return <button onClick={handleClick}>Increment Counter</button>;
}