Replies: 1 comment
-
在现有特性上已经可以解决 如果你想要控制请求时序例如使用 如果你单纯想要中断前面的请求可以在beforeRequest中记录正在请求的method,然后有相同请求发送的时候中断之前的,这里有个alova@3的示例代码可以尝试一下 const requestingMethods = {};
createAlova({
// ...
beforeRequest(method) {
// 相同的请求,method.key都是相同的
const lastSameMethod = requestingMethods[method.key];
if (lastSameMethod) {
lastSameMethod.abort();
}
requestingMethods[method.key] = method;
},
responded: {
onComplete(method) {
delete requestingMethods[method.key];
}
}
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
例如同一时间同一个api被触发了多次,是否可以添加一个配置自动 abort 前面的请求,保留最后一个?
Beta Was this translation helpful? Give feedback.
All reactions