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 entire consumer surface. There is deliberately no synchronous “get it or null” probe: a probe only answers “now” and never tells you when “now” changed, so calling one 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 'obsidian-dev-utils/obsidian/plugin/plugin-api';Signature:
function watchPluginApi(params: WatchPluginApiParams): PluginApiRef<TApi>Parameters:
| Parameter | Type | Description |
|---|---|---|
params | WatchPluginApiParams | The parameters for the watch. |
Returns: PluginApiRef<TApi> — The live reference.
Links to this page: