Skip to content
New issue

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

Let users cancel abortable functions #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Wolvenstone
Copy link

@Wolvenstone Wolvenstone commented Jul 8, 2023

Adds a cancel function to the result of useAsyncAbortable()

const result = useAsyncAbortable(async (signal: AbortSignal) => {}, []);
result.cancel();

This aborts the AbortSignal that is passed into the executed function. This is very helpful for longer running queries where you want to give users the opportunity to cancel running requests.

It reuses the logic that is already in place to abort queries whenever a new async call is made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant