We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
First of all, I think this is a great project. Many thanks for the effort.
Is this the correct way to use deferFn
deferFn
const deferFn = ([args]: [Required<Credentials>]) => cognitoService.confirmResetPassword(args); const { isPending, run } = useAsync({ deferFn, }); const [verificationCode, setVerificationCode] = useState<{ verificationCode: string; }>();
I think I would prefer useFetch with {defer: true} but I am not using fetch for these calls.
useFetch
{defer: true}
fetch
Is there a better way or shy can deferFn no be like promiseFn only it is not executed immediately.
promiseFn
The text was updated successfully, but these errors were encountered:
That looks fine, although I'd rename args to credentials because it's more descriptive of what it represents.
args
credentials
deferFn and promiseFn are very similar, the difference being:
run
Sorry, something went wrong.
@ghengeveld thanks, i get why args has to be an array.
one more thing if you don’t mind.
i think this indexer in the AsyncOptions type is making the type not strong typed. i can have:
useAsync({ promiseFon: fn })
and it the compiler won’t recognise the wrong property.
you could take a second type argument and augment the options
export type AsyncOptions<T, P = {}> = { promise?: Promise<T> promiseFn?: PromiseFn<T> deferFn?: DeferFn<T> watch?: any watchFn?: (props: AsyncProps<T>, prevProps: AsyncProps<T>) => any initialValue?: T onResolve?: (data: T) => void onReject?: (error: Error) => void reducer?: ( state: ReducerAsyncState<T>, action: AsyncAction<T>, internalReducer: (state: ReducerAsyncState<T>, action: AsyncAction<T>) => ReducerAsyncState<T> ) => AsyncState<T> dispatcher?: ( action: AsyncAction<T>, internalDispatch: (action: AsyncAction<T>) => void, props: AsyncProps<T> ) => void debugLabel?: string } & P;
No branches or pull requests
Hi,
First of all, I think this is a great project. Many thanks for the effort.
Is this the correct way to use
deferFn
I think I would prefer
useFetch
with{defer: true}
but I am not usingfetch
for these calls.Is there a better way or shy can
deferFn
no be likepromiseFn
only it is not executed immediately.The text was updated successfully, but these errors were encountered: