findPluginApi<TApi>
Looks another plugin’s API up ONCE, and answers for this moment only.
It applies the same selection rule as watchPluginApi and hands out the same revocable handle, but it subscribes to nothing, so it never learns that the answer changed. That makes it the right shape for a free function that has no component to own a watch and runs on a user-driven path, such as a backlink lookup made while a rename is handled. It is the wrong shape for onload: plugins load in an unspecified order, so a null there means “not yet” as often as “not installed”. Code that has a component and reads the API more than once should hold a watchPluginApi ref instead.
Import:
import { findPluginApi } from '@mnaoumov/obsidian-lib/plugin/plugin-api';Signature:
function findPluginApi(params: FindPluginApiParams<NoInfer<TApi>>): TApi | nullParameters:
| Parameter | Type | Description |
|---|---|---|
params |
FindPluginApiParams<NoInfer<TApi>> | The parameters for the lookup. |
Returns: TApi | null — The API, or null when no live record satisfies the range and the contract.
Links to this page: