t-hooks
    Preparing search index...

    Function useTaskCallbackState

    • Task-based asynchronous callback hook

      Task equivalent to useCallback hook allowing to perform asynchronous callbacks

      Task execution is automatically interrupted in case of additional calls or unmounting. This way, only one task is running at the given time

      Type Parameters

      • A extends any[]

        callback arguments type

      • T

        resulting task resolve type

      Parameters

      • taskFunction: TaskFunction<A, T>

        task taskFunction to be invoked as callback

      • deps: DependencyList

        dependency list

      Returns readonly [(...args: A) => Task<T>, boolean, () => void]

      callback to be invoked, current execution status (running or not) and cancellation function

      Task is not cancelled on hook re-render, but is cancelled on the next call instead