main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
881 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import { DependencyList } from 'react';
|
---|
| 2 | import { FunctionReturningPromise, PromiseType } from './misc/types';
|
---|
| 3 | export declare type AsyncState<T> = {
|
---|
| 4 | loading: boolean;
|
---|
| 5 | error?: undefined;
|
---|
| 6 | value?: undefined;
|
---|
| 7 | } | {
|
---|
| 8 | loading: true;
|
---|
| 9 | error?: Error | undefined;
|
---|
| 10 | value?: T;
|
---|
| 11 | } | {
|
---|
| 12 | loading: false;
|
---|
| 13 | error: Error;
|
---|
| 14 | value?: undefined;
|
---|
| 15 | } | {
|
---|
| 16 | loading: false;
|
---|
| 17 | error?: undefined;
|
---|
| 18 | value: T;
|
---|
| 19 | };
|
---|
| 20 | declare type StateFromFunctionReturningPromise<T extends FunctionReturningPromise> = AsyncState<PromiseType<ReturnType<T>>>;
|
---|
| 21 | export declare type AsyncFnReturn<T extends FunctionReturningPromise = FunctionReturningPromise> = [
|
---|
| 22 | StateFromFunctionReturningPromise<T>,
|
---|
| 23 | T
|
---|
| 24 | ];
|
---|
| 25 | export default function useAsyncFn<T extends FunctionReturningPromise>(fn: T, deps?: DependencyList, initialState?: StateFromFunctionReturningPromise<T>): AsyncFnReturn<T>;
|
---|
| 26 | export {};
|
---|
Note:
See
TracBrowser
for help on using the repository browser.