Executes a process asynchronously with progress tracking and error handling.

  • Type Parameters

    • Data extends unknown = any

      The type of data to be processed.

    • Result = void

      The type of the process result.

    Parameters

    • process: (item: IProcess<Data>) => Result | Promise<Result>

      The process function to be executed on each item.

    • options: IParams<Data, Result>

      Optional parameters for customizing the process behavior.

      • delay

        The delay in milliseconds before each item processing. Default is 0.

      • onError

        Callback function to be executed when an error occurs during processing. Default is an empty function.

      • onProgress

        Callback function to be executed on each progress update. Default is an empty function.

      • onFinish

        Callback function to be executed when all items are finished processing. Default is an empty function.

      • onBegin

        Callback function to be executed when the process begins. Default is an empty function.

      • onEnd

        Callback function to be executed when the process ends. Default is an empty function.

    Returns {
        errors: IError[];
        execute: (items: IProcess<Data>[]) => void;
        label: string;
        loading: boolean;
        progress: number;
    }

    An object containing the execute function, loading state, progress, and errors.