y-socket.io
y-socket.io copied to clipboard
Add option to debounce updates and debounce awareness updates
- Allow users to debounce their updates to the server (the client accumulates the updates and merges them before syncing at the interval), merging the Y.js updates into a single update over that given period, also to be able to notify users that their updates were not synced to the server.
- Allow users to debounce their awareness updates to the server (sending an update once every given time to the server)
Notes on debouncing:
- The deboucing allow users to specify the time over which to delay, i.e. the debounce time, but also a max wait to ensure that updates on content changes and awareness are sent at least once every
n
time - I provide an
onPending
function which is used to indicate that there is local debounced data which has not yet been sent (i.e. changes which have not yet "been saved") - Added a
localOnly
flag to use.local
on Socket.IO to only broadcast to local sockets, even when using an adapter for document updates, since those updates would need to be applied via some other mechanism anyway to synchronize the content between the servers (since the y.js document is stateful, and not synchronizing the server instances causes them to essentially fail) - Added a
timeoutForAck
argument to specify the timeout for the first "sync-step-1" since it can fail (i.e. not receive an acknowledgement) and so I added a log for such a case - I fixed the type annotation for the handshake for the
authenticate
argument