t-hooks
    Preparing search index...

    Function useCompatTaskCallbackState

    • Type Parameters

      • A extends any[]

        callback argument types

      • R

        resulting task resolve type

      Parameters

      • taskFunction: TaskFunction<A, R>

        task function to be invoked as callback

      • deps: DependencyList

        dependency list; the task function is memoized with these dependencies

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

      callback returning the started task, current execution status, and cancellation function, as [callback, running, cancel]

      Use useTaskCallbackState when the callback task resolves to void. This hook remains for callbacks whose task resolves to a result.

      Task-based asynchronous callback hook that returns the started task

      Each call starts a task and returns it. A later call or unmount cancels the previous task asynchronously, from an effect cleanup via setTimeout. cancel() clears the running flag immediately and schedules that same cancellation.