Skip to content

API reference > @kontsedal/olas-realtime > PatcherHandlers

PatcherHandlers type ​

Map of event.type literal → handler. Each key is one type of the discriminated union, and its handler receives that variant only:Extract<TEvent, { type: K }>, so 'comment-added': (ev) => ev.comment needs no narrowing.

The '*' wildcard key receives every event the dispatcher saw, typed as the whole union, including those a specific handler already consumed. Use it for logging, instrumentation, or "I don't know all the types yet" diagnostics.

Signature:

typescript
export type PatcherHandlers<TEvent extends {
  type: string;
}> = { [K in TEvent['type']]?: (event: Extract<TEvent, {
  type: K;
}>) => void; } & {
  '*'?: (event: TEvent) => void;
};

Released under the MIT License.