Skip to content

on

on<T, K>(topic, listener): () => void

Defined in: astrobase/src/events/events.ts:61

Subscribes a callback to an event topic.

T extends Topics = Topics

A map of topic names and their emitted value types.

K extends string | number | symbol = keyof T

The topic name to subscribe to.

K

The topic name to subscribe to.

Listener<T[K]>

A listener callback function that will be invoked each time an event is emitted.

A function that directly unsubscribes the listener without needing to manually invoke off.

(): void

void