Skip to content

subscribeEvent<Source, EventName>

Subscribes to an event on an Events source and returns the raw EventRef (parity with Events.on). Typed wrapper: the event name and callback arguments are autocompleted from the source’s overloads.

Import:

import { subscribeEvent } from 'obsidian-dev-utils/obsidian/events';

Signature:

function subscribeEvent(params: SubscribeEventParams<Source, EventName>): EventRef

Parameters:

ParameterTypeDescription
paramsSubscribeEventParams<Source, EventName>The subscription parameters.

Returns: EventRef — The EventRef for the registered handler.


Links to this page: