ComputedMap<K, V> class abstract

An in-memory, partially- or fully-observable key-value store.

Similar to the ObservableMap from the observable package, but with the following upsides:

  • Individual keys can be observed in an asymptotically optimal manner.
  • Has value semantics thanks to immutability (using fast_immutable_collections).
  • Supports reactive operations consuming and emitting ComputedMaps.
Available extensions

Constructors

ComputedMap.fromChangeStream(Computed<ChangeEvent<K, V>> stream)
Constructs a ComputedMap that tracks stream. Initialized to the empty map.
factory
ComputedMap.fromChangeStreamWithPrev(ChangeEvent<K, V> f(IMap<K, V>?))
Like ComputedMap.fromChangeStream, but lets the change stream computation depend on the snapshot of the map.
factory
ComputedMap.fromIMap(IMap<K, V> m)
Constructs a constant ComputedMap from a given IMap.
factory
ComputedMap.fromPiecewise(Iterable<K> domain, V f(K key))
Constructs a constant ComputedMap defined by f over the key domain domain.
factory
ComputedMap.fromPiecewiseComputed(Iterable<K> domain, Computed<V> f(K key))
Like .fromPiecewise, but the values are defined by reactive computations.
factory
ComputedMap.fromSnapshotStream(Computed<IMap<K, V>> stream)
Constructs a ComputedMap from the given snapshot stream.
factory

Properties

changes → Computed<ChangeEvent<K, V>>
A computation representing the last change event on this map.
no setter
hashCode int
The hash code for this object.
no setterinherited
isEmpty → Computed<bool>
A computation representing the emptyness of this map.
no setter
isNotEmpty → Computed<bool>
Opposite of isEmpty.
no setter
length → Computed<int>
A computation representing the length of this map.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
snapshot → Computed<IMap<K, V>>
A computation representing the snapshot of this map.
no setter

Methods

add(K key, V value) ComputedMap<K, V>
Reactively adds the pair key, value to this reactive map.
addAll(IMap<K, V> other) ComputedMap<K, V>
Reactively adds other to this reactive map.
addAllComputed(ComputedMap<K, V> other) ComputedMap<K, V>
Reactively adds other to this reactive map.
cartesianProduct<K2, V2>(ComputedMap<K2, V2> other) ComputedMap<(K, K2), (V, V2)>
Returns the cartesian product of this ComputedMap with other as a ComputedMap.
cast<RK, RV>() ComputedMap<RK, RV>
Reactively casts the entries of this reactive map.
containsKey(K key) → Computed<bool>
Returns a computation representing if this reactive map contains key.
containsValue(V value) → Computed<bool>
Returns a computation representing if this reactive map contains value.
groupBy<K2>(K2 key(K key, V value)) ComputedMap<K2, ComputedMap<K, V>>
Groups this map using the given key function as a ComputedMap.
groupByComputed<K2>(Computed<K2> key(K key, V value)) ComputedMap<K2, ComputedMap<K, V>>
As with groupBy, but groups the elements by the reactive value of a computation.
join<V2>(ComputedMap<K, V2> other) ComputedMap<K, (V, V2)>
Returns the inner join of this with other as a ComputedMap.
lookup<V2>(ComputedMap<K, V2> other) ComputedMap<K, (V, V2?)>
Returns the left join of this ComputedMap with other as a ComputedMap.
map<K2, V2>(MapEntry<K2, V2> convert(K key, V value)) ComputedMap<K2, V2>
Reactively maps each entry of this reactive map by convert.
mapComputed<K2, V2>(Computed<Entry<K2, V2>> convert(K key, V value)) ComputedMap<K2, V2>
Reactively maps each entry of this reactive map by convert.
mapValues<V2>(V2 convert(K key, V value)) ComputedMap<K, V2>
Reactively maps all values of this reactive map by convert.
mapValuesComputed<V2>(Computed<V2> convert(K key, V value)) ComputedMap<K, V2>
Reactively maps all values of this reactive map by convert.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
putIfAbsent(K key, V ifAbsent()) ComputedMap<K, V>
Reactively adds key to this reactive map using the value returned by ifAbsent, if key does not already exist.
remove(K key) ComputedMap<K, V>
Reactively removes key from this reactive map.
removeWhere(bool test(K key, V value)) ComputedMap<K, V>
Reactively removes all entries satisfying test from this reactive map.
removeWhereComputed(Computed<bool> test(K key, V value)) ComputedMap<K, V>
Reactively removes all entries satisfying test from this reactive map.
toString() String
A string representation of this object.
inherited
update(K key, V update(V value), {V ifAbsent()?}) ComputedMap<K, V>
Reactively updates the value for key.
updateAll(V update(K key, V value)) ComputedMap<K, V>
A special case of mapValues where the input and output types are the same.
updateAllComputed(Computed<V> update(K key, V value)) ComputedMap<K, V>
A special case of mapValuesComputed where the input and output types are the same.

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](K key) → Computed<V?>
Returns a computation representing the given key of this map.