import { A as AsyncState, F as Falsy, E as ExtractValues, k as ExtractErrors } from '../types-5EvFF6wb.js'; import 'keyweaver'; import 'react'; /** * A hook to retrieve the current values and errors from multiple {@link states}. * If any of {@link states} isn't loaded, the component using this hook suspends. * Ensure the component is wrapped in a component to handle the loading state. * If any of {@link states} fails and {@link safeReturn} is not enabled, an error is thrown. * * @example * ```jsx * const DataComponent = () => { * const [data1, data2] = useAll([asyncState1, asyncState2]); * * return ( *
*
Data: {JSON.stringify(data1)}
*
Data: {JSON.stringify(data2)}
*
* ); * }; * * const SafeComponent = () => { * const [[data1, data2], errors] = useAll([asyncState1, asyncState2], true); * * if (errors.some((error) => error)) { * return
Error occurred
; * } * * return ( *
*
Data: {JSON.stringify(data1)}
*
Data: {JSON.stringify(data2)}
*
* ); * }; * * const App = () => ( * <> * Loading...}> * * * Loading...}> * * * * ); * ``` */ declare const useAll: , SafeReturn extends boolean = false>(states: S, safeReturn?: SafeReturn) => SafeReturn extends false ? ExtractValues : Readonly<[values: ExtractValues, errors: Readonly<{ [index in keyof S]: undefined; }>] | [values: ExtractValues, errors: ExtractErrors]>; export { useAll as default };