@salesforce/core
Version:
Core libraries to interact with SFDX projects, orgs, and APIs.
19 lines (18 loc) • 586 B
TypeScript
type LWWRegisterState<T> = {
timestamp: bigint;
value: T;
};
/** a CRDT implementation. Uses timestamps to resolve conflicts when updating the value (last write wins)
* mostly based on https://jakelazaroff.com/words/an-interactive-intro-to-crdts/
*
* @param T the type of the value stored in the register
*/
export declare class LWWRegister<T> {
state: LWWRegisterState<T>;
constructor(state: LWWRegisterState<T>);
get value(): T;
get timestamp(): bigint;
set(value: T): void;
merge(incoming: LWWRegisterState<T>): LWWRegisterState<T>;
}
export {};