getAPI
function getAPI(
app: App,
options?: ExtendedMetadataCacheOptions
): ExtendedMetadataCacheHandleAcquires a shared ExtendedMetadataCache instance. If another plugin using the same API major version has already created one, that instance is reused. Returns a handle with a release() method.
Parameters
app— The ObsidianAppinstance (available asthis.appin any plugin).options— Optional configuration. See Options.
Returns
ExtendedMetadataCacheHandle with:
api— TheExtendedMetadataCacheAPIinstance.release()— Call this on plugin unload to decrement the reference count.
Example
async onload() {
const handle = getAPI(this.app);
const cache = handle.api;
// ... use cache ...
}
onunload() {
handle.release();
}Related
- Singleton Pattern — how sharing works
- hasAPI — check without creating
- createExtendedMetadataCache — non-shared instance
- Options — configuration