LWWRegister<T> class

LWW-Register (Last-Writer-Wins register) - single value with timestamp. When merging, the value with the later timestamp wins. Ties are broken by nodeId comparison for determinism.

Constructors

LWWRegister(T _value, String _nodeId)
Create a LWW-Register with an initial value and nodeId.

Properties

hashCode int
The hash code for this object.
no setterinherited
nodeId String
The node that last wrote the value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timestamp DateTime
The timestamp of the last write.
no setter
value → T
The current value.
no setter

Methods

merge(LWWRegister<T> other) LWWRegister<T>
Merge with another LWW-Register. The register with the later timestamp wins. Ties are broken by comparing nodeIds.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
set(T newValue) → void
Set a new value, updating the timestamp.
setWithTimestamp(T newValue, DateTime newTimestamp) → void
Set a new value with a specific timestamp (for importing).
toJson() Map<String, dynamic>
Serialize to a JSON-serializable map.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromJson<T>(Map<String, dynamic> json, T fromValue(dynamic)) LWWRegister<T>
Deserialize from a JSON map.