watchPluginApi<TApi>
Watches another plugin’s API and returns a live PluginApiRef whose PluginApiRef.value stays correct across the provider’s load, unload, and re-enable.
This is the consumer surface for anything that has a component. Its one-shot sibling findPluginApi only answers “now” and never tells you when “now” changed, so calling it during onload reads null and invites the conclusion “not installed”. A consumer that needs a synchronous answer inside a callback whose signature forbids await — checkCallback(isChecking): boolean, canExecute(), a settings-row visible predicate — holds the ref (or the value it maintains) in a field and reads that, which is both cheaper and correct across BOTH edges.
Import:
import { watchPluginApi } from '@mnaoumov/obsidian-lib/plugin/plugin-api';Signature:
function watchPluginApi(params: WatchPluginApiParams<NoInfer<TApi>>): PluginApiRef<TApi>Parameters:
| Parameter | Type | Description |
|---|---|---|
params |
WatchPluginApiParams<NoInfer<TApi>> | The parameters for the watch. |
Returns: PluginApiRef<TApi> — The live reference.
Links to this page: