v5.3.0
More detailed change events
IStorage instances now emit more detailed change events when a document is written (modified, created, deleted).
IStorage.onWrite
is a newly added Emitter which sends out objects like this:
export type WriteEvent = {
kind: 'DOCUMENT_WRITE',
// a write is "local" if it comes from IStorage.set()
// otherwise it's "remote" (it came from a sync).
isLocal: boolean,
document: Document,
}
Use it like this:
myStorage.onWrite((event: WriteEvent) => {
console.log(`a document changed at ${document.path}`);
});
Deprecations
The previous Emitter, IStorage.onChange
, still exists and is triggered in the same situations, but it does not send any info to callbacks. It's deprecated and will be removed eventually.