Function fromCallback

  • Generic callback task

    Usefull for creating custom tasks from success and error callbacks and cancelaton function. Synchronous callbacks are not supported,

    Type Parameters

    • H

    • R

    Parameters

    • create: ((resolve, reject, cancel) => H)

      task body with success and error callbacks

        • (resolve, reject, cancel): H
        • Parameters

          • resolve: ((result) => void)
              • (result): void
              • Parameters

                • result: R

                Returns void

          • reject: ((error) => void)
              • (error): void
              • Parameters

                • error: any

                Returns void

          • cancel: (() => void)
              • (): void
              • Returns void

          Returns H

    • onCancel: ((handler) => void)
        • (handler): void
        • Parameters

          • handler: H

          Returns void

    Returns Task<R>

    task resolving to success value

    See

    fromFuction

    Example

    export function timeout(delay: number) {
    return fromCallback<NodeJS.Timeout, void>((resolve) => setTimeout(() => resolve(), delay), clearTimeout);
    }

Generated using TypeDoc