diff --git a/docs/content/1.get-started/3.tips/3.aborting-procedures.md b/docs/content/1.get-started/3.tips/3.aborting-procedures.md new file mode 100644 index 0000000..bec123e --- /dev/null +++ b/docs/content/1.get-started/3.tips/3.aborting-procedures.md @@ -0,0 +1,24 @@ +--- +title: Aborting Procedures +--- + +# Aborting Procedures + +tRPC adheres to the industry standard when it comes to aborting procedures. All you have to do is pass an `AbortSignal` to the query-options and then call its parent `AbortController`'s `abort` method. + +```ts [composables/useGetTodo.ts] +export default function useGetTodo(id: number) { + const { $client } = useNuxtApp() + const ac = new AbortController() + + onScopeDispose(() => { + ac.abort() + }) + + return useAsyncData(() => { + return $client.todo.getTodo.query(id, { + signal: ac.signal + }) + }) +} +```