SharedDataStore
A device-local query replica backed by vault files. Call synchronize after transport changes or periodically. No timer or event handler outlives the consumer: the consumer schedules synchronization and owns unloading.
Import:
import { SharedDataStore } from '@mnaoumov/obsidian-lib/data-stores/shared-data-store';Signature:
export class SharedDataStoreMethods
| Method | Returns | Description |
|---|---|---|
| compact() | Promise<void> | Publishes a complete chunked snapshot and trims only this device's acknowledged journal segments. Retired devices rejoin by merging snapshots; tombstones remain in snapshots to prevent resurrection. |
| containsTransportPath(path) | boolean | Recognizes transport files, roots, and ancestor folder operations for consumer event filters. |
| delete(key) | Promise<void> | Deletes a register or removes the currently observed additions of a set member. |
| entries() | [string, unknown][] | Reads the current local query replica. |
| get(key) | unknown | Reads a register or set membership from the current local query replica. |
| relocate(location) | Promise<void> | Relocates only this plugin/store subtree; keep opening with the original anchor parameters. |
| set(key, value) | Promise<void> | Writes one register value, or adds a member to an observed-remove set. |
| setMany(entries) | Promise<void> | Publishes a batch of register writes, appended to this device's open journal segment and split into bounded ones. Segments are individually durable; a failed batch can have a published prefix and can be retried safely. |
| setSyncEnabled(isEnabled) | Promise<void> | Toggles transport without changing identity or causal state. Persist the preference in consumer settings. Enabling publishes a complete checkpoint so offline sequences cannot leave gaps. |
| synchronize() | Promise<void> | Merges complete snapshots and contiguous journal history, then publishes its durable acknowledgement. Partial deliveries remain pending; a later call retries them. No acknowledgement skips a missing sequence. |
| static open(params) | Promise<SharedDataStore> | Opens and synchronizes a store, restoring its device identity exclusively from IndexedDB. |