Skip to main content

Module doc

Module doc 

Expand description

CRDT helpers: writes that keep Automerge documents from churning, and typed reads.

Splicing a whole string on every keystroke (delete all, reinsert new) costs O(len) ops per edit and, since Automerge tombstones every inserted element forever, O(len²) accumulated ops over a typing session — the store gets slower until the app appears to freeze.

splice_text_diffed / put_text_diffed diff old vs. new down to the common prefix + suffix and splice only the changed middle span, so one keystroke costs one op. read_text and read_str_or_text read text back.

Structs§

TextEdit
The splice splice_text_diffed applied, in characters — Automerge Text is char-addressed, not byte-addressed. A no-op reports {pos:0, del:0, ins:0}.

Functions§

document
The document and object a widget pass lent as its AppModel and ModelPath.
document_ref
Read-only document.
put_text_diffed
Creates the Text object on first use (inserting the whole value); subsequent calls splice only the diff.
read_str_or_text
A string stored either as a string scalar or as a Text object, for fields that migrated from one representation to the other.
read_text
The contents of a Text object; see read_str_or_text for a field that may hold a string scalar instead.
splice_text_diffed
Prefer put_text_diffed when you have a parent object + key and want the Text created on first use.