Avbryta procedureanrop
Inofficiell Beta-översättning
Denna sida har översatts av PageTurner AI (beta). Inte officiellt godkänd av projektet. Hittade du ett fel? Rapportera problem →
tRPC följer branschstandarden för att avbryta procedurer. Allt du behöver göra är att skicka med en AbortSignal till fråge- eller mutationsalternativen, och sedan anropa abort-metoden på AbortController-instansen om du behöver avbryta förfrågan.
utils.tsts// @filename: server.tsimport {createTRPCProxyClient ,httpBatchLink } from '@trpc/client';import type {AppRouter } from 'server.ts';constproxy =createTRPCProxyClient <AppRouter >({links : [httpBatchLink ({url : 'http://localhost:3000/trpc',}),],});// 1. Create an AbortController instance - this is a standard javascript APIconstac = newAbortController ();// 2. Pass the signal to a query or mutationconstquery =proxy .userById .query ('id_bilbo', {signal :ac .signal });// 3. Cancel the request if neededac .abort ();
utils.tsts// @filename: server.tsimport {createTRPCProxyClient ,httpBatchLink } from '@trpc/client';import type {AppRouter } from 'server.ts';constproxy =createTRPCProxyClient <AppRouter >({links : [httpBatchLink ({url : 'http://localhost:3000/trpc',}),],});// 1. Create an AbortController instance - this is a standard javascript APIconstac = newAbortController ();// 2. Pass the signal to a query or mutationconstquery =proxy .userById .query ('id_bilbo', {signal :ac .signal });// 3. Cancel the request if neededac .abort ();