fix: useRequest pollingInterval invalid after staleTime is enabled - #2568
Open
electroluxcode wants to merge 4 commits into
Open
fix: useRequest pollingInterval invalid after staleTime is enabled#2568electroluxcode wants to merge 4 commits into
electroluxcode wants to merge 4 commits into
Conversation
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[English Template / 英文模板]
🤔 这个变动的性质是?
🔗 相关 Issue
fix #2505
💡 需求背景和解决方案
发现是 plugin 之间相互影响了,staleTime 导致了缓存,使得returnNow要求立刻返回值, 而pollingInterval 要求轮询值, 导致了 useRequest 的 staleTime 和 pollingInterval 不能够按照预期工作。因为返回值后就永远不会轮询。
正确的做法应该是 判断应该是是处于 returnNow 和 pollingInterval 的交叉状态,如果是这个状态,那么将 缓存值传递到各个plugin的 onSuccess和onFinish等方法中去(原来的代码直接
return Promise.resolve,导致轮询永远无法触发),然后再执行return Promise.resolve。 假如不是这个交叉状态,按原来的逻辑走就行然后原来的plugin中并不能共享 returnNow stopNow,pollingNow 之类的状态,插件中需要对这些状态进行判断,这个pr对上面的问题进行了简单的重构,
补一个用于测试的实例
📝 更新日志
☑️ 请求合并前的自查清单