프로시저 호출 중단
비공식 베타 번역
이 페이지는 PageTurner AI로 번역되었습니다(베타). 프로젝트 공식 승인을 받지 않았습니다. 오류를 발견하셨나요? 문제 신고 →
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 ();