Skip to content

A way to know if an update has been stored (feedback) #28

@WofWca

Description

@WofWca

Checklist

[x] Are you reporting a bug? Use github issues for bug reports and feature requests. For general questions, please use https://discuss.yjs.dev/
[x] Try to report your issue in the correct repository. Yjs consists of many modules. When in doubt, report it to https://github.com/yjs/yjs/issues/

Is your feature request related to a problem? Please describe.
Apparently not all updates are guaranteed to be stored (is it itself a bug? This needs to be documented at least). For example, if you do an update and close/reload the tab immediately, it won't show up on the next load.

There's no conventional way to know in what state the document has been stored in indexedDB. Has the update that I just made been stored? Is it safe to close the tab now?

Describe the solution you'd like
Expose some getter, or method, or add an event (or all at the same time), that lets you determine if the document is stored in indexedDB in the same state as it is in JS right now.

Also I guess this should apply to other persistence adapters (leveldb).

Describe alternatives you've considered
Perhaps additionally a method that upon calling stores the latest update

Additional context
My case:
I'm developing an app that builds the state from a list of updates (like this one). The list is an external thing that persists between page reloads. For performance, I want to store the state of the Y.Doc in browser storage in order to not rebuild it from the list of updates each time. For this I need to remember the index of the last update in the list that has been cached in indexedDB. But I don't know the index because it's not guaranteed that every update made on the doc with the y-indexeddb adapter attached will be saved.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions