Skip to main content

LazyCompute<K, V>

Reactive function that is computed lazily and memoized.

Context.createLazyCollection accepts a constructor function of a top-level class that implements this LazyCompute interface. Each implementation of LazyCompute provides a compute function, which produces values for some key, possibly using a self reference to get/produce other lazily-computed results.

Type Parameters

Type ParameterDescription
K extends JsonType of keys / inputs.
V extends JsonType of values / outputs.

Methods

compute()

compute(self, key): Iterable<V>

Compute the values of the lazy function for a given key.

When computing the values for a requested key, the compute function is provided with a LazyCollection that is tabulating the input-output relation of this function. This collection can be queried in order to look up the values for previously computed keys, or to make a recursive call to compute if the requested key has not yet been computed.

Parameters

ParameterTypeDescription
selfLazyCollection<K, V>The collection tabulating this lazy function.
keyKThe requested key / input.

Returns

Iterable<V>

The values of the lazy function for key.