/** * useAsyncOperation Hook * * Generic hook for managing async operation state (loading, error) * Consolidates repeated try-catch patterns across hooks */ export interface AsyncOperationState { loading: boolean; error: string | null; } export interface UseAsyncOperationReturn extends AsyncOperationState { execute: (operation: () => Promise, errorMessage?: string) => Promise; clearError: () => void; setLoading: (loading: boolean) => void; setError: (error: string | null) => void; } /** * Hook for managing async operation state * * @param defaultErrorMessage - Default error message when error is not an Error instance * @returns State and methods for managing async operations * * @example * ```tsx * const { loading, error, execute } = useAsyncOperation('Failed to load plugins'); * * const loadPlugins = useCallback(async () => { * const result = await execute(async () => { * return await fetchPlugins(); * }); * if (result) { * setPlugins(result); * } * }, [execute]); * ``` */ export declare function useAsyncOperation(defaultErrorMessage?: string): UseAsyncOperationReturn; //# sourceMappingURL=useAsyncOperation.d.ts.map