Yjs Deep Dive#
These are my notes while prototyping and researching Yjs for our shopping list app.
yjs/yjs#
dmonad on the Yjs Community Kevin Jahns (creator of yjs)#
Introduction to SyncedStore | SyncedStore - Javascript CRDT based real-time sync
you should think very carefully about the schema of your data. Because it’s really hard to change it once you have active users
I could not find a way to implement ordering.
store.items.splice
cannot be used to write stuff.
Syncing document to Postgres database - Yjs Community
Y.encodeStateAsUpdate(doc) returns a Uint8Array of the entire Doc.
Subsequent updates can be saved individually when the doc changes:
Easy to understand explanation of how Yjs works - Yjs Community
In CRDTs we usually don’t think in terms of events. For me, it would be more natural to think about state. Yjs maintains a linked list. Eventually, all clients will end up with the same linked list. CRDTs give you an algorithm to “put that state together” so that everyone ends up with the same state.
This is very different to Operation Transformation, where we think in terms of operations that need to be transformed so that everyone ends up with the same content.
Why are yjs types writen with jsdocs and not typescript? - Yjs Community
Server#
https://channels-yroom.readthedocs.io/en/latest/
django channels
MIT
yjs/y-redis: Alternative backend for y-websocket
AGPL
pg_crdt - an experimental CRDT extension for Postgres
proof of concept by supabase
Random Stuff#
y-octo: Why we’re not using yrs
multi-threading, Memory efficiency, libraries, „yrs panics everywhere, rather than returning the Result type“
Triplit | The Fullstack Database
typescript, relational
-
„a Yjs server with persistence and auth“
Rust and Typescript
How Yjs works from the inside out - YouTube interview with Kevin Jahns (2020)
valtiojs/valtio-yjs: valtio-yjs makes yjs state easy alpha software
Building Document-Centric, CRDT-Native Editors | Hacker News
initial document contents
https://discuss.yjs.dev/t/initial-offline-value-of-a-shared-document/465/13 recommends to apply an initial state to the document
https://discuss.yjs.dev/t/merging-changes-from-one-document-into-another/499/2 is referenced (code example)
unique list
do not use Y.Map as top level elements
I suggest not to use maps as the top-level data structure. Deleted properties will always take up space (the key-name can’t be removed). https://discuss.yjs.dev/t/moving-elements-in-lists/92/10
sorted list
yjs/yjs#
Flutter#
Journey from yjs in python to octobase_flutter:
Looks promising, but incomplete and partly abandoned like everything else in this space: toeverything/OctoBase
If AFFiNE really uses OctoBase and is any good, then maybe that’s no problem. 🤷