docs: add aborting procs

This commit is contained in:
wobsoriano
2022-11-13 11:05:47 -08:00
parent eea6406d5a
commit e14827e0c7

View File

@@ -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<GetTodosOutput, ErrorOutput>(() => {
return $client.todo.getTodo.query(id, {
signal: ac.signal
})
})
}
```