Usage
React
Effect stream
API
| Method | Description |
|---|---|
insert(pos: number, text: string, ttlMs?) | Insert characters at position |
delete(pos: number, length: number, ttlMs?) | Delete length characters starting at pos |
value() | Returns current text as string |
onChange(fn) | Subscribe — returns unsubscribe function |
stream() | Returns an Effect Stream<string> that emits on every change |
Conflict semantics
- Concurrent inserts at the same position are ordered by author ID (deterministic, total order)
- Concurrent delete + insert: the insert survives — deletions only remove characters that existed at the time of the delete op
- Idempotent: applying the same op twice has no effect
CRDT key prefix
Use therg: prefix by convention: