Zum Inhalt springen
Deutsch

ORMapOptions

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

ORMapOptions<K> = object

Defined in: src/crdt/ORMap.ts:39

Observed-Remove map, where each value is itself a CRDT. Keys follow OR-Set add-wins semantics; values merge per-key via their own merge. The natural fit when you want a logical map and each cell needs its own conflict-free type — e.g. carts where every cart is itself an ORSet of items, or per-tenant options where each tenant’s options is an LWWMap.

const empty = ORMap.empty<string, ORSet>(); const a = empty.update(‘alice’, ‘cart-1’, () => ORSet.empty(), (cart) => cart.add(‘alice’, ‘apple’)); const b = empty.update(‘bob’, ‘cart-1’, () => ORSet.empty(), (cart) => cart.add(‘bob’, ‘banana’)); a.merge(b).get(‘cart-1’)!.value() // → [‘apple’, ‘banana’] (per-key inner-CRDT merge)

Add-wins for keys. Concurrent put(key) | remove(key) resolves via the underlying ORSet’s tag rules: the put carries a tag the remove never saw, so it survives. See ORSet for the formal mechanism.

Inner-CRDT decoder injection (fromJSON). Because the value type is itself a CRDT, deserialisation needs to know which CRDT to build for each value. Pass a decodeValue: (json) => V callback to fromJSON; the DistributedData extension wires its decodeCrdt dispatcher in for you. Standalone usage:

ORMap.fromJSON(json, (v) => ORSet.fromJSON(v as ORSetJson))

Element identity. Same JSON-stringify default + identity override pattern as the rest of the map types — pass { identity: k => ... } for non-JSON-serialisable keys.

K

readonly optional identity?: (k) => string

Defined in: src/crdt/ORMap.ts:40

K

string