t-tasks
    Preparing search index...

    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

        cancelation handler type

      • R

        returned task resolve type

      Parameters

      • create: (
            resolve: (result: R) => void,
            reject: (error: any) => void,
            cancel: () => void,
        ) => H

        task body with success and error callbacks

      • onCancel: (handler: H) => void

        cancelation function intended for stopping task execution

      Returns Task<R>

      task resolving to success value

      fromFunction

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