import { SetStateAction } from "react";
import { Primitive } from "type-fest";
type Arr<X> = [X, React.Dispatch<SetStateAction<X>>];
export type FunctionMap = {
    [f: string]: ((...args: any[]) => Promise<any>) | Object | Primitive;
};
export type Control<E extends any = any> = {
    error?: E;
    loading: boolean;
};
export declare function useRawAsynControl<E = any, F extends FunctionMap = {}>(functionsToWrap: F | undefined, [error, setError]: Arr<E | undefined>, [loading, setLoading]: Arr<boolean>): {
    process: (asyncFn: (() => Promise<any>) | Promise<any>) => Promise<any>;
    loading: boolean;
    error: E | undefined;
    setError: import("react").Dispatch<SetStateAction<E | undefined>>;
    setLoading: import("react").Dispatch<SetStateAction<boolean>>;
} & F;
export declare function useAsyncControl<E = any, F extends {
    [f: string]: ((...args: any[]) => Promise<any>) | Object | Primitive;
} = {}>(functionsToWrap?: F): {
    process: (asyncFn: Promise<any> | (() => Promise<any>)) => Promise<any>;
    loading: boolean;
    error: Error | E | undefined;
    setError: import("react").Dispatch<SetStateAction<Error | E | undefined>>;
    setLoading: import("react").Dispatch<SetStateAction<boolean>>;
} & F;
/**
 * This hook provides a way to handle async operations storing the loading state, or the error when it fails, it does not store information returned from the functions.
 * @param functionsToWrap The functions to wrap in control.
 * @returns
 */
export default useAsyncControl;
