platform-bible-utils
    Preparing search index...

    Class AsyncVariable<T>

    This class provides a convenient way for one task to wait on a variable that another task sets.

    Type Parameters

    • T
    Index

    Constructors

    • Creates an instance of the class

      Type Parameters

      • T

      Parameters

      • variableName: string

        Name to use when logging about this variable

      • rejectIfNotSettledWithinMS: number = 10000

        Milliseconds to wait before verifying if the promise was settled (resolved or rejected); will reject if it has not settled by that time. Use -1 if you do not want a timeout at all. Defaults to 10000 ms

      Returns AsyncVariable<T>

    Accessors

    • get promise(): Promise<T>

      Get this variable's promise to a value. This always returns the same promise even after the value has been resolved or rejected.

      Returns Promise<T>

      The promise for the value to be set

    Methods

    • Reject this variable's promise for the value with the given reason

      Parameters

      • reason: string

        This variable's promise will be rejected with this reason

      • throwIfAlreadySettled: boolean = false

        Determines whether to throw if the variable was already resolved or rejected. Defaults to false

      Returns void

    • Resolve this variable's promise to the given value

      Parameters

      • value: T

        This variable's promise will resolve to this value

      • throwIfAlreadySettled: boolean = false

        Determines whether to throw if the variable was already resolved or rejected. Defaults to false

      Returns void