interface Resolution { readonly data: D; } interface Rejection { readonly error: E; } declare type Pending = undefined; declare type Result = Resolution | Rejection | Pending; interface UseAsync { result: Result; call(): void; isResolved(_result: Result): _result is Resolution; onResolve(resolutionCallback: (data: D) => R, fallbackValue?: F): R | F | undefined; isRejected(_result: Result): _result is Rejection; onReject(rejectionCallback: (error: E) => R, fallbackValue?: F): R | F | undefined; isPending(): boolean; onPending(pendingCallback: () => R, fallbackValue?: F): R | F | undefined; } /** * Provides an interface for handling an AJAX request in a React component. * Returns `result` which represents either an object with `data` or `error`, * of is `undefined`, while the request is still pending. * * @param {() => Promise} callback An async callback that makes a request * * @returns `on-` callbacks and `is-` flags provide a declarative way to work with needed `result` * state, and a `sendRequest` function that makes a request when called. */ declare function useAsync(callback: () => Promise): UseAsync; export default useAsync;