Google's diff-match-patch for concurrent update

258 views Asked by At

So, I've got a google docs type feature in my app which can be edited by multiple users concurrently. Diff-match-patch works fine for me when only one user updates the doc.

But it generates wrong data when let's say the doc is already updated by user1 and it's not delivered to user2(due to socket error or network error).

For example - 'Stack overflow is 55666.' is my doc, which is being edited by multiple users. Now, user1 changes it to 'Stack overflow is 6.'

and calculates diff and sends it to the server but before that user2 has already changed it to something else, say 'Stack overflow is 25552.'. Now when the patch(from user1) is applied, it generated wrong result which could be 'Stack overflow is 252.'

So how can I manage it to achieve concurrent update? I can use Socket so that if someone else changes, I send that change to other users so that they can have the latest updated data but if the change is a lot the UX can be bad as other users may see a random change in view.

0

There are 0 answers