Class UncertainAsyncOp<T, E>

Same as an AsyncOp, but allows returning errors in case the operation fails.

Type Parameters

  • T

    Type of the return value. Caller must ensure to provide the valid type.

  • E = string

    The failure type. If the operation fails, this type will be returned.

Hierarchy (view full)

Properties

[toStringTag]: string

Accessors

  • get error(): E
  • Retrieves the error returned by the async operation. Only valid if AsyncOpBase.isError returns true.

    Returns E

    Return error of the async operation.

  • get identifier(): object
  • An opaque identifier that uniquely identifies this AsyncOp on the system. The returned is not specified, but guaranteed to be the same during runtime.

    Returns object

  • get isComplete(): boolean
  • Returns true if the async operation has completed.

    Returns boolean

  • get isFailed(): boolean
  • Returns true if the async operation has failed.

    Returns boolean

  • get isPending(): boolean
  • Returns true if the async operation is pending completion or failure.

    Returns boolean

  • get value(): T
  • Retrieves the value returned by the async operation. Only valid if AsyncOpBase.isComplete returns true.

    Returns T

    Return value of the async operation.

Methods

  • Attaches a failure handler to the async op.

    Parameters

    • onError: ((error: E) => void)

      The callback to be called as continuation.

        • (error): void
        • Parameters

          • error: E

          Returns void

    Returns this

    this

  • Attaches a failure handler to the async op.

    Parameters

    • onError: ((error: E) => void)

      The callback to be called as continuation.

        • (error): void
        • Parameters

          • error: E

          Returns void

    Returns this

    this

  • Attaches a finalization handler to the async op.

    Parameters

    • OptionalonFinally: (() => void)

      The callback to be called in case of success or failure.

        • (): void
        • Returns void

    Returns this

    this

  • Determines if this async op matches the specified identifier.

    Parameters

    • identifier: object

    Returns boolean

  • Attaches a continuation to the async op.

    Parameters

    • onComplete: ((result: T) => void)

      The callback to be called as continuation.

        • (result): void
        • Parameters

          • result: T

          Returns void

    • onError: ((error: E) => void)

      The callback to be called as error continuation.

        • (error): void
        • Parameters

          • error: E

          Returns void

    Returns this

    this

  • Attaches a continuation to the async op.

    Parameters

    • onComplete: ((result: T, error?: E, identifier?: object) => void)

      The callback to be called as continuation.

        • (result, error?, identifier?): void
        • Parameters

          • result: T
          • Optionalerror: E
          • Optionalidentifier: object

          Returns void

    Returns this

    this