We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我使用了轮询功能,想要的效果是当轮询得到的数据满足某个要求时就停止轮询,所以我在Options.onSuccess中判断得到的数据,然后适时调用cancel函数,如下面的代码所示
Options.onSuccess
const {data, run, loading, cancel } = useRequest(getQrStatusReq, { pollingInterval : 2000, manual: true, onError:(error)=>{console.log(error)}, onSuccess:(res)=>{ if(res.data === 1){ cancel() login() } } });
但这样行不通,它并不能使轮询停止。这是我的第一个疑问,为什么不能? 于是我就换了一个方法,在watch函数中监测data,如果条件满足则调用cancel函数,这个方法可以达到要求,不过我想知道这个方法是否符合规范。因此,我的第二个疑问是在哪里去调用cancel函数才是符合规范的?
data
The text was updated successfully, but these errors were encountered:
fix: polling can be canceled in onSuccess and onError #198
onSuccess
onError
60c5a66
已经修复了,onSuccess 和 onError 应该能取消轮询才是正确的。待会会发个版
Sorry, something went wrong.
原来如此,没想到是一个bug,等你发新版后我再试试
已更新2.x正式版,请使用 npm install vue-requst 或者 yarn install vue-requst 更新
npm install vue-requst
yarn install vue-requst
No branches or pull requests
问题描述 Problem Description
我使用了轮询功能,想要的效果是当轮询得到的数据满足某个要求时就停止轮询,所以我在
Options.onSuccess
中判断得到的数据,然后适时调用cancel函数,如下面的代码所示但这样行不通,它并不能使轮询停止。这是我的第一个疑问,为什么不能?
于是我就换了一个方法,在watch函数中监测
data
,如果条件满足则调用cancel函数,这个方法可以达到要求,不过我想知道这个方法是否符合规范。因此,我的第二个疑问是在哪里去调用cancel函数才是符合规范的?The text was updated successfully, but these errors were encountered: