Skip to content

CustomMergeResolver

Defined in: src/persistence/replicated/ConflictResolver.ts:78

Wraps a user-provided commutative merge function. Use this when you have domain knowledge that LWW doesn’t capture — e.g. the conflicting events are both “deposit X” and you can simply add the amounts.

new CustomMergeResolver((a, b) => ({ kind: ‘merged’, amount: a.event.amount + b.event.amount, }));

E

new CustomMergeResolver<E>(merge): CustomMergeResolver<E>

Defined in: src/persistence/replicated/ConflictResolver.ts:79

(a, b) => E

CustomMergeResolver<E>

resolve(a, b): E

Defined in: src/persistence/replicated/ConflictResolver.ts:80

Pick a single event from a concurrent pair. Implementations MUST be commutative — resolve(a, b) must equal resolve(b, a). Return one of the inputs, or a synthesised merge of both — either is fine as long as the result is deterministic across replicas.

ConflictCandidate<E>

ConflictCandidate<E>

E

ConflictResolver.resolve