@tsdotnet/lazy - v1.1.0
    Preparing search index...

    Class ResolverBase<T>Abstract

    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 (View Summary)

    • default
    Index

    Constructors

    • Type Parameters

      • T

      Parameters

      • valueFactory: Func<T>
      • _allowReset: boolean = false

      Returns ResolverBase<T>

    Properties

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

    Accessors

    • get canReset(): boolean

      Will return true if allowReset is true and a value factory still exists.

      Returns boolean

    • get error(): any

      The error value if previous faulted.

      Returns any

    • get isFaulted(): boolean

      True if the resolution faulted.

      Returns boolean

    • get isValueCreated(): boolean

      Returns true if the value has been created.

      Returns boolean

    Methods

    • Is called when this object is disposed. Should NOT be called directly. Override this method to handle disposal.

      Returns void

    • Uses the provided factory to generate the value and returns that value for subsequent requests.

      Returns T

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

      Returns boolean