MCPcopy Create free account
hub / github.com/anomalyco/opencode / on

Function on

packages/tui/src/context/event.ts:22–30  ·  view source on GitHub ↗
(
    type: T,
    handler: (event: Extract<Event, { type: T }>, metadata: EventMetadata) => void,
  )

Source from the content-addressed store, hash-verified

20 }
21
22 function on<T extends Event["type"]>(
23 type: T,
24 handler: (event: Extract<Event, { type: T }>, metadata: EventMetadata) => void,
25 ) {
26 return subscribe((event: Event, metadata: EventMetadata) => {
27 if (event.type !== type) return
28 handler(event as Extract<Event, { type: T }>, metadata)
29 })
30 }
31
32 return {
33 subscribe,

Callers

nothing calls this directly

Calls 2

subscribeFunction · 0.70
handlerFunction · 0.50

Tested by

no test coverage detected