mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 20:19:33 +01:00
docs: add aborting procs
This commit is contained in:
24
docs/content/1.get-started/3.tips/3.aborting-procedures.md
Normal file
24
docs/content/1.get-started/3.tips/3.aborting-procedures.md
Normal 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
|
||||
})
|
||||
})
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user