And it really is simple – you treat your state as plain old JS objects, you mutate them however you like, and it all just works. But wait, there is

Serverless Collaborative Hierarchical TODO App in 200 LoC

submited by
Style Pass
2022-01-14 03:00:15

And it really is simple – you treat your state as plain old JS objects, you mutate them however you like, and it all just works. But wait, there is more.

For past few months I have been researching CRDTs a lot. CRDT stands for Conflict-free Replicated Datatype, and you can imagine it as any data structure (string, array, map, etc.), but it is replicated, i.e. there are multiple copies – I have a copy, you have a copy, and Joe has a copy. All our copies are mutable – any of us can change it at any time – so we have to somehow synchronize them. We can have a 3rd party arbiter that would do it for us, but ideally we don't want to introduce any central authority. If there isn't an arbiter that would resolve conflicts for us, we have to do it in some distributed way. And this is why CRDTs exist.

CRDTs are relatively new tech, but they are gaining traction in the business – non-exhaustive list of CRDT implementations. Since we are in the JS context, the most interesting implementation for us is Yjs. And surprise, surprise – Valtio has Yjs support.

Leave a Comment