Linked documents
mweidner037 opened this issue · 0 comments
Many apps require multiple documents (CRuntime
s), so that different parts of the app can have different permissions, be loaded independently, be stored in different places, etc.
Sometimes these documents are linked to each other. E.g.:
- A main document could store a
CPresence
for shared cursors in a separate document, so thatCPresence
heartbeats don't cause the main document to re-save constantly. - A large text CRDT could be split into sub-documents for different sections so that they don't all have to load at once. It's easiest if the sub-documents all use
Position
s from a singleCPositionSource
, which would live in a separate always-loaded document. - One text document hyperlinks to a section in another text document.
To make 1 & 2 possible, we would need a way to link documents' causal orders. In case 1, a shared cursor movement in the CPresence
doesn't make sense until you receive causally prior operations that created the cursor's Position
. In case 2, each text CRDT depends on causally prior operations in the CPositionSource
to understand the list order.
Specifically, we need the ability to have one CRuntime
buffer messages until causally prior messages are received by another CRuntime
. This seems like a neat and relatively easy feature to add.
We could also make it possible to implement case 3 without keeping both documents in memory simultaneously. E.g., store the reference as a CollabID
+ Position
, and add fallback code in case the user clicks on a link to a section that you haven't received yet. This mostly requires an example in the docs, but we also need a way to safely ask whether a Position
exists. (Currently, asking a list about a not-yet-existent Position
will throw an error.)