import { useCallback, useState } from "react";
import useAsyncControl from "../useAsyncControl";
/**
 * Provides a way to manually trigger a function and store it's result on a state
 */
export default function useManualInit(funcToMemoize, depArr) {
    const { process, error } = useAsyncControl();
    const [memo, setMemo] = useState();
    const initCb = useCallback(() => process(funcToMemoize)
        .then((result) => {
        setMemo(result);
        return result;
    })
        .catch(() => setMemo(null)), depArr);
    return [initCb, memo, error];
}
//# sourceMappingURL=useManualInit.js.map