LazyCollection<K, V>
A lazy reactive collection, whose values are computed only when queried.
A LazyCollection is a reactive collection of entries that associate keys to values where the entries are computed on-demand in response to queries.
Once an entry has been computed, later queries will not need to recompute it, unless it's dependencies have changed.
Extends
Type Parameters
| Type Parameter | Description |
|---|---|
K extends Json | Type of keys. |
V extends Json | Type of values. |
Methods
getArray()
getArray(key): V & DepSafe[]
Get (and potentially compute) all values associated to key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | K | The key to query. |
Returns
V & DepSafe[]
The values associated to key.
getUnique()
getUnique(key, _default?): V & DepSafe
Get (and potentially compute) the single value associated to key.
For collections that do not use the generality of associating multiple values to a key, getUnique saves some boilerplate over getArray.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | K | The key to query. |
_default? | { ifMany: V; ifNone: V; } | |
_default.ifMany? | V | Default value for the case where multiple values are associated to the given key |
_default.ifNone? | V | Default value for the case where zero values are associated to the given key |
Returns
V & DepSafe
The value associated to key.
Throws
SkipNonUniqueValueError if key is associated to either zero or multiple values and no suitable default is provided.