
Jake Lazaroff is set to guide us through CRDTs, starting from the basics to building a collaborative pixel art editor. We'll learn about CRDT types, explore LWW Registers and Maps, and see how they enable seamless collaboration.
CRDTs Unveiled
CRDT stands for Conflict - free Replicated Data Type. It's a data structure stored on different computers. Peers can update their states instantly without network checks. There are state - based and operation - based CRDTs. This post focuses on state - based ones. CRDTs are great for collaborative apps like Google Docs and Figma.
Last Write Wins Register
The simplest register is the Last Write Wins Register (LWW Register). It overwrites its value with the last written one, using timestamps to determine the order. If the received timestamp is greater, it updates the value. The code for LWW Register is provided, and it matches the CRDT interface well.
Last Write Wins Map
Most programs need more complex CRDTs than LWW Registers. The Last Write Wins Map (LWW Map) holds multiple values. It's composed of LWW Registers. The merge function iterates through keys and passes states to corresponding registers. It also has methods like set, get, delete, and has.
Importance of Tombstones
When deleting keys in an LWW Map, instead of removing them, we set the register value to null. This creates "tombstones". Without tombstones, incorrect deletions can occur during syncing, as shown in the playground demos.
Future Outlook
In the next post, Lazaroff will use what we've learned to build a collaborative pixel art editor. This shows the practical applications of CRDTs in real - world scenarios.
编辑观点:CRDTs offer a promising solution for building collaborative apps. Their ability to handle conflicts without a central server is revolutionary. As more apps require real - time collaboration, CRDTs are likely to see wider adoption.
4万+



被折叠的 条评论
为什么被折叠?



