Is there a way to compare two state vectors from two clients to see if any changes need to be sent between them? I have a situation where the state vector of the “server” is posted and needs to be used by the client to figure out if the client needs to pull from the server based on the server’s state vector.
That would not work because the server is “passive”. The client needs to request my server that it needs an update, but I want to avoid creating extra check requests to figure out if the client is out of sync with the server state vector.
Shouldn’t the state vector itself be enough to figure out if an update is needed?
the state vector does not include all information to represent the state of a Yjs document. Deletions are not tracked by the state vector - the “delete set” must always be exchanged to sync two clients.
You can, however, create a hash-sum over the encoded Yjs document to check whether two clients are synced. Alternatively, it might be a good idea to introduce a “last-modified” timestamp. The client only needs to sync when the timestamp is updated.