Skip to content

waitForPlugin<TPlugin>

Waits for another plugin to become PluginAvailability.Available.

Resolves at once when it already is, which covers a consumer reloaded after its dependency. Otherwise it re-reads the state on every app.plugins changed and every obsidian-lib:plugin-loaded broadcast, so a plugin enabled, updated or reloaded later is picked up with no polling. It subscribes before its first read, so a change landing in between cannot be missed. Every listener and timer is removed when it settles.

Import:

import { waitForPlugin } from '@mnaoumov/obsidian-lib/plugin/plugin-instance';

Signature:

function waitForPlugin(params: WaitForPluginParams<NoInfer<TPlugin>>): Promise<TPlugin>

Parameters:

Parameter Type Description
params WaitForPluginParams<NoInfer<TPlugin>> The WaitForPluginParams.

Returns: Promise<TPlugin> — A Promise resolving with the instance.


Links to this page: