Class Lazy<T>

Represents a value that is initialized in a lazy manner, i.e. not until it is needed

Type Parameters

  • T

Constructors

Properties

Methods

Constructors

Properties

builder: Builder<T, void>
value: T | Promise<T>

Methods

  • Creates a new Lazy<S> value. The initializer takes the value of this Lazy<T> and uses it to create a Lazy<S>

    Multiple values can be chained; they won't initialize until the last one is resolved.

    Type Parameters

    • S

    Parameters

    • builder: Builder<S, T>

      the initializing function. Since this could be doing anything, it can have side effects

    Returns Lazy<S>

  • Gets the value of the lazy object, initializing it, if necessary

    Returns Promise<T>

  • Create a Lazy by providing the function that will be called when the value is first needed

    Type Parameters

    • NT

    Parameters

    • builder: Builder<NT, void>

      the initializing function. Since this could be doing anything, it can have side effects

    Returns Lazy<NT>