Search...

lazy

declare function lazy<T>(cb: () => T): () => T;
declare function lazy<T>(cb: () => T): () => T;
Lazy is a wrapper around a value that is computed lazily. It is useful for cases where the value is expensive to compute and the computation may not be needed at all.
Example
const value = lazy(() => computeExpensiveValue());
const value = lazy(() => computeExpensiveValue());
NameConstraintsOptionalDefaultDescription
TNoThe type of the value
NameTypeOptionalDescription
cb() => TNoThe callback to lazily evaluate