Skip to content

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