프로시저 호출 중단
tRPC는 프로시저를 중단하기 위한 표준 AbortController/AbortSignal API를 지원합니다. 쿼리 또는 뮤테이션 옵션에 AbortSignal을 전달하고, 요청을 취소해야 하는 경우 AbortController 인스턴스의 abort 메서드를 호출하기만 하면 됩니다.
utils.tstsimport {createTRPCClient ,httpBatchLink } from '@trpc/client';import type {AppRouter } from './server';constclient =createTRPCClient <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 =client .userById .query ('id_bilbo', {signal :ac .signal });// 3. Cancel the request if neededac .abort ();
utils.tstsimport {createTRPCClient ,httpBatchLink } from '@trpc/client';import type {AppRouter } from './server';constclient =createTRPCClient <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 =client .userById .query ('id_bilbo', {signal :ac .signal });// 3. Cancel the request if neededac .abort ();