La referencia de la API está disponible solo en inglés por ahora.

useEventEmitter

function
devtools-ui/src/hooks/useEventEmitter.ts:47
signature
useEventEmitter(storeId): { emit: (channel: string, type: string, payload: unknown) => void }

Emits events to a store from the extension.

Parameters

NameTypeDescription
storeIdnull | stringThe 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>;
}