Ordered collections in a mind-meld state, e.g. a queue, which devices change in any order without conflict.
An ordered collection is a map of id to an entry with a :rank, a string that sorts by the entry's place. A move can go in a second map of the same ids, whose entries hold only the new rank, so that a move never brings back what another device removed. A schema marks both :ranked?:
{:queue {:depth 1 :ranked? true}
:queue-moves {:depth 1 :ranked? true}}
The comments name the source of each part, and where it departs from it:
Ordered collections in a mind-meld state, e.g. a queue, which devices
change in any order without conflict.
An ordered collection is a map of id to an entry with a :rank, a string
that sorts by the entry's place. A move can go in a second map of the
same ids, whose entries hold only the new rank, so that a move never
brings back what another device removed. A schema marks both :ranked?:
{:queue {:depth 1 :ranked? true}
:queue-moves {:depth 1 :ranked? true}}
The comments name the source of each part, and where it departs from it:
- Wallace, Realtime Editing of Ordered Sequences, Figma, 2017,
https://www.figma.com/blog/realtime-editing-of-ordered-sequences/
- Kleppmann, Gomes, Mulligan and Beresford, Interleaving anomalies in
collaborative text editors, PaPoC 2019,
https://doi.org/10.1145/3301419.3323972
- Kleppmann, Moving Elements in List CRDTs, PaPoC 2020,
https://doi.org/10.1145/3380787.3393677(append state path entries ids at)The state with the ids written at at to the end of the ordered
entries at path, unless they're there already. The entries should
have their moves applied.
The `state` with the `ids` written at `at` to the end of the ordered `entries` at `path`, unless they're there already. The `entries` should have their moves applied.
(appended state path entries ids)The writes that put the ids in order at the end of the ordered
entries at path in state, as pairs of a path and a function.
The entries should have their moves applied, so that the ids go after
an entry that was moved to the end. An id that's already there stays
where it is. The ranks are in a block of the state's device, so that ids
that another device appends at the same time don't mix with them.
The writes that put the `ids` in order at the end of the ordered `entries` at `path` in `state`, as pairs of a path and a function. The `entries` should have their moves applied, so that the ids go after an entry that was moved to the end. An id that's already there stays where it is. The ranks are in a block of the state's device, so that ids that another device appends at the same time don't mix with them.
(problem schema state)A description of the first entry whose :rank isn't a rank, in the
collections of state that the schema marks :ranked?, or nil. Such a
rank, e.g. from another version of an app, makes sorting throw.
A description of the first entry whose :rank isn't a rank, in the collections of `state` that the `schema` marks :ranked?, or nil. Such a rank, e.g. from another version of an app, makes sorting throw.
(rank-at entries id index)The rank that moves the entry id to index among the ordered
entries. An index that isn't whole is rounded down, and NaN counts as
0.
The rank that moves the entry `id` to `index` among the ordered `entries`. An index that isn't whole is rounded down, and NaN counts as 0.
(rank-at-end entries)A rank after every live entry of the ordered entries.
A rank after every live entry of the ordered `entries`.
(rank-between entries before-id after-id)A rank between the entries of the ids before-id and after-id of the
ordered entries, either of which can be nil for an end, and after any
entries that share the rank of before-id.
A rank between the entries of the ids `before-id` and `after-id` of the ordered `entries`, either of which can be nil for an end, and after any entries that share the rank of `before-id`.
(ranked entries)The live entries of an ordered collection as [id entry] pairs by
rank, and by stamp and device when two ranks are equal.
The live `entries` of an ordered collection as [id entry] pairs by rank, and by stamp and device when two ranks are equal.
(with-moves entries moves)The ordered entries, each at the place of its live entry in moves
when that's the later of the two.
The ordered `entries`, each at the place of its live entry in `moves` when that's the later of the two.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |