The ResolverBase class handles resolving a factory method and detects recursion. Since JS does not have a synchronization mechanism (lock or otherwise) we have to prevent getValue from double triggering the value factory (optimistic concurrency) or returning return a value that is intermediate between resolving and resolved.

Type Parameters

  • T

Hierarchy

Constructors

  • Type Parameters

    • T

    Parameters

    • valueFactory: (() => T)
        • (): T
        • Returns T

    • allowReset: boolean = false

    Returns Lazy<T>

Properties

_resolveState: {
    created: null | boolean;
    error?: unknown;
    factory?: Func<T>;
    value?: T;
}

Type declaration

  • created: null | boolean
  • Optional error?: unknown
  • Optional factory?: Func<T>
  • Optional value?: T

Accessors

  • get canReset(): boolean
  • Will return true if allowReset is true and a value factory still exists.

    Returns

    Returns boolean

  • get error(): any
  • The error value if previous faulted.

    Returns any

  • get isFaulted(): boolean
  • True if the resolution faulted.

    Returns

    Returns boolean

  • get isValueCreated(): boolean
  • Returns true if the value has been created.

    Returns boolean

  • get value(): T
  • Returns the resolved value.

    Returns T

  • get valueReference(): undefined | T
  • Gets the value regardless if resolved or not. Does not trigger the value factory.

    Returns

    Returns undefined | T

Methods

  • Will attempt to reset this resolve if possible and returns true if successfully reset.

    Returns

    Returns boolean

  • Compares the values of two Lazy for equality.

    Returns

    Parameters

    Returns boolean

  • Creates a Lazy by inferring T.

    Returns

    Type Parameters

    • T

    Parameters

    • valueFactory: (() => T)
        • (): T
        • Returns T

    • allowReset: boolean = false

    Returns Lazy<T>

Generated using TypeDoc