ueberdosis / hocuspocus

The CRDT Yjs WebSocket backend for conflict-free real-time collaboration in your app.
https://tiptap.dev/docs/hocuspocus/introduction
MIT License
1.21k stars 117 forks source link

Avoiding unnecessary onStoreDocument hooks call on last connection close #767

Closed ebads67 closed 8 months ago

ebads67 commented 8 months ago

This is proposal to address the issue #766

websiddu commented 8 months ago

it would also be better if there is away to call the onStoreDocument hook on demand, e.g if the user exists the page and then reopens the page, immediately they would not get the changes that were not committed yet, they would not see the changes that they just made?

ebads67 commented 8 months ago

it would also be better if there is away to call the onStoreDocument hook on demand, e.g if the user exists the page and then reopens the page, immediately they would not get the changes that were not committed yet, they would not see the changes that they just made?

Being able to call onStoreDocument might be a good idea for some scenarios. But I'm not trying to address that in this PR. Also this PR neither makes nor fixes the potential issue of not getting the latest changes if opening the document right after closing it.

What this PR does is avoiding unnecessary onStoreDocument calls if there is no changes waiting to be saved in the debouncer.