Function useAsyncAction

Executes an asynchronous action with options for handling loading, error, and cancellation.

  • Type Parameters

    • Data extends unknown = any

      The data type returned by the action.

    • Payload extends unknown = any

      The payload type passed to the action.

    Parameters

    • run: ((p: Payload) => Data | Promise<Data>)

      The action function to execute.

    • options: IParams = {}

      Optional parameters for customizing behavior.

    Returns IResult<Data, Payload>

    • An object containing loading, error, and execute properties.