Open
Description
需求动机
使用 XRequest 发起请求后,希望能主动终止请求。目前是否能通过自定义 fetch 的方式实现?
const controllerRef = useRef<AbortController | null>(null);
controllerRef.current = new AbortController();
const { signal } = controllerRef.current;
const exampleRequest = () => {
const mockFetch = fetch(BASE_URL + PATH, {signal});
return XRequest({
baseURL: BASE_URL + PATH,
model: MODEL,
fetch: mockFetch,
})
};
const onRequest = await exampleRequest.create(
...
};
<Sender
onSubmit={(nextContent) => {
onRequest(nextContent);
}}
onCancel={() => controllerRef.current?.abort();}
/>
提议的 API 是什么样的?
controllerRef.current = new AbortController();
const { signal } = controllerRef.current;
XRequest({
baseURL: BASE_URL + PATH,
model: MODEL,
signal: signal
})
Metadata
Assignees
Labels
No labels