MetadataCache.on('changed') method
MetadataCache › on(‘changed’)
Official
Called when a file has been indexed, and its (updated) cache is now available.Signature:
on(name: "changed", callback: (file: TFile, data: string, cache: CachedMetadata) => unknown, ctx?: unknown): EventRefParameters:
| Parameter | Type | Description |
|---|---|---|
| name | "changed" | Should be 'changed'. |
| callback | (file: TFile, data: string, cache: CachedMetadata) => unknown | The callback function. |
| ctx? | unknown | The context passed as this to the callback function. |
Returns: EventRef — The event reference.
Example:
app.metadataCache.on('changed', (file, data, cache) => { console.log(file, data, cache);});```
Note: This is not called when a file is renamed for performance reasons.You must hook the {@link obsidian#Vault .on | Vault.on(name: 'rename')} event for those.