Many parts of y.js are still magic to me; slowly trying to de-mistify this by reading the docs, including the magnificent blogs on YATA by Bartosz Sypytkowski. However, I am punching a little bit outside my weight class here, please bear with me…
My current bottlenecks in my understanding:
- There are no real/wall clocks involved, at all, only monotonically increased counters, per peer; correct?
- Are there any other clocks involved besides this clock?
- I know of the problems with real clocks (drift, etc., and know that these cannot be relied on)
- If there are no real clocks, and no global clock, then I am not really understanding how a fool-proof causal order can be determined (maybe it can’t?). Scenario below.
In my offline-first application I actually don’t deal with text very much. In fact in this stage I am not even implementing collaborative text editing. I plan to use y.js mostly for keeping docs with mostly objects (y.map) in sync between peers.
Consider these chronological events:
- Alice @ counter 1; { myBoolean: null → true }
- Document syncs with Bob. Bob then goes offline.
- Bob @ counter 1; { myBoolean: true → false }
- Alice @ counter 2; { myBoolean: true → false }
- Alice @ counter 3; { myBoolean: false → true }
- Bob comes back online, and receives the document (myBoolean=true).
When Bob does an applyUpdate of his change (false) to the document.
How can y.js know that the result should be true and not false? As all it has are counter-clocks.
I have not tried out this scenario (just started playing with y.js, at this point not yet ready to test these kinds of scenario’s). What would the outcome actually be?