DEV Community

Andrey Agibalov
Andrey Agibalov

Posted on

Explain Operational Transformation Like I'm Five

Top comments (1)

Collapse
 
aarohmankad profile image
Aaroh Mankad • Edited

Operational Transformation is focused around the concept of creating robust collaborative experiences through incremental changes in your data.

Broadly, an Operational Transform includes an operation (INSERT, DELETE, etc.) and the content to push to that operation.

Let's take Google Docs as an example.

We want to add the word "hello" at index 56 in the document (represented here as a simple string). The Operation would look something like:

InvokeOperation("INSERT", { content: "hello", index: 56 });

This assumes that InvokeOperation would first update the local representation of your document, then call your API with the correct information.

Your API then must handle receiving these Operations and queuing them to modify the document.

Note: this is very similar to Redux, which uses the concept of Operational Transform for state management. An Operation is an "Action", which invokes a "Reducer", which then modified the actual state. You "dispatch" Actions to modify the data.