Function: useEvents()
ts
function useEvents(types: readonly EventType[], handler: EventHandler): void;Defined in: src/wirestate-react/events/use-events.ts:27
Subscribes a component to multiple event types on the EventBus.
Parameters
| Parameter | Type | Description |
|---|---|---|
types | readonly EventType[] | Array of event types (strings or symbols) to filter by. |
handler | EventHandler | Function invoked when any of the specified events are emitted. |
Returns
void
Remarks
Similar to useEvent, but allows listening for a collection of event types using a single handler. The handler and type list are synced via useRef to avoid stale closures.
Example
tsx
useEvents(["USER_UPDATED", "USER_DELETED"], (event) => {
refreshList();
});