Function: useEventsHandler()
ts
function useEventsHandler(handler: EventHandler): void;Defined in: src/wirestate-react/events/use-events-handler.ts:28
Subscribes a component to all events on the EventBus without type filtering.
Parameters
| Parameter | Type | Description |
|---|---|---|
handler | EventHandler | Event handler invoked for every emitted event. |
Returns
void
Remarks
Useful for logging, debugging, or cross-cutting concerns that need to see every event passing through the bus. The handler is synced via useRef to avoid stale closures. The subscription is automatically cleaned up on unmount.
Example
tsx
useEventsHandler((event) => {
console.log("Event received:", event.type, event.payload);
});