General steps for using resgate for live-collaboration type editor



I am looking for framework for writing web-based live-collaboration (like google docs, or - recently - LiveShare of vscode) service. So far Resgate looks promising, but I wonder what are general steps of writing such application (given the state of written data might change frequently). Can someone point me with general steps of implementation?



Hi, and welcome to the forum,

This is an interesting topic, with numerous possible implementations depending on requirements.

This article about Differential Synchronization explains some approaches to the general subject.

Resgate can help with reliably transferring data between service and clients, but most of the implementation will still be left up to you.

I would probably end up with a few resources like this:

Type Resource Example payload Description
call document.32.latest {“rid”:“document.32.ver.1234”} The method returns a resource reference to the latest document version.
get document.32.ver.1234 { "text": "The cat in the hat" } The document for a given version. Static model that never changes.
get document.32.patches?ver=1234 [ {"rid":"document.32.patch.1235"} ] A query collection containing reference to patches that can be applied upon version 1234 of the document.
get document.32.patch.1235 {"diff":"@@..diff..@@"} A patch that, when applied to document ver 1234, would produce document ver 1235.
call document.32.ver.1234.patch Params: {"diff":"@@..diff..@@"} A call method for the client to call when it has edited the text. The service will take the provided diff params and try to apply it to the document. On success, it will produce a resulting patch that is provided to all clients through the get document.32.patches?ver=xxx query collection, using a query event.

("@@..diff..@@" would be some sort of diff format that describes the changes.)

Not sure if that helps.

And on a side note, the roadmap contains a plan on implementing better support for patching documents like this:

Extend the RES Protocol with a document resource type. The new type would be used for larger texts where updates are sent as diff patches instead of replacements for the entire text. :leftwards_arrow_with_hook:

It would make it a bit easier, but still leave the conflict resolution bit to the developer.

Best regards,

1 Like

Thank you, this really lighten up!