Skip to content

IncrementalFileIndexComponentConstructorParams<T>

Dependencies of an incremental index. Persistence must validate its own schema.

Import:

import type { IncrementalFileIndexComponentConstructorParams } from '@mnaoumov/obsidian-lib/components/incremental-file-index-component';

Signature:

export interface IncrementalFileIndexComponentConstructorParams<T>

Properties

PropertyTypeDescription
accepts(file: TFile) => booleanFiles accepted by this index, for example Markdown files only.
appAppThe application owning the vault.
indexFile(params: IndexFileParams) => TBuilds an immutable record synchronously; text is never retained by this component.
load() => Promise<ReadonlyMap<string, IndexedFileRecord<T>>>Reads validated records, or an empty map for a missing/incompatible cache.
onRemove(path: string) => voidRemoves a record from a consumer's secondary index. Called for known records only.
onSet(path: string, record: T) => voidUpdates a consumer's secondary index, including restored records.
save(records: ReadonlyMap<string, IndexedFileRecord<T>>) => Promise<void>Persists a snapshot; writes are serialized and retried by the next flush after failure.
shouldAwaitMetadataChange?(file: TFile) => booleanWhether a create or modify of the file is followed by a metadata-cache changed event carrying its text, as for Markdown notes. Such a file drops its stale projection and is not read; its record returns with that event, or with the next startup or IncrementalFileIndexComponent.rescan when Obsidian raises none (a modify that left the content unchanged). Consumers must treat a file without a record as unknown. Defaults to never.
shouldMoveRecordsOnRename?booleanWhether a projection depends on text alone, so a rename moves it with its stats instead of reading the file again. A file renamed to a path accepts rejects loses its record either way. Defaults to false.

Links to this page: