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§
- Text
Edit - The splice
splice_text_diffedapplied, in characters — AutomergeTextis 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
AppModelandModelPath. - document_
ref - Read-only
document. - put_
text_ diffed - Creates the
Textobject 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
Textobject, for fields that migrated from one representation to the other. - read_
text - The contents of a
Textobject; seeread_str_or_textfor a field that may hold a string scalar instead. - splice_
text_ diffed - Prefer
put_text_diffedwhen you have a parent object + key and want theTextcreated on first use.