How to use Y.PermanentUserData?

You should only reuse a client-id if you are absolutely sure that no one else with the same client-id is producing conflicting changes. If you can assure that, you can set ydoc.clientID = myclientid (wait, don’t do it!). But in most cases, it is a really bad idea with unintentional side-effects. In the best case, you save a little bit of data (please do some tests, the overhead really is insignificant, especially with the v2 encoder). In the worst case, your document gets corrupted with no way to recover.

If you use session-storage, you must ensure that no other window is currently using your client-id (or at least that there are no conflicts). This might be true for most applications that only produce edits when a user opens a window and then performs changes. But at some point in the future, you might associate a timeout to a change and your document gets corrupted.

I don’t recommend it. There is a huge potential for corrupted documents.

Nope :wink: There are alternative shared editing solutions that used time to order messages. But they have increased potential for conflicts because it can’t be expected that computers have synced computer clocks.

Right, you would need to store this information in an additional field.

1 Like