-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
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
Async> cache async response regardless of req order #2012
Async> cache async response regardless of req order #2012
Conversation
Addresses JedWatson#2009. There is a WIP test -- I can't figure out how to simulate the exact scenario that this patch fixes in the test. The current test returns positive even without my change. Suggestions would be appreciated -- thanks!
Addresses the second issue mentioned in the linked issue. While the previous commit makes this change unnecessary for regular use cases, the issue is still present when debouncing. By clearing out `this._callback`, intermediary searches (e.g. 'Ti' when 'Tim' is already fetched) won't cause the options for 'Tim' to change when the request for 'Ti' completes.
Thanks @timhwang21 This looks good to merge, I'll see what I can do to get the test working |
@timhwang21 I fixed the test so it works correctly now. There are a couple of changes I made (including slightly different math for the delay and different cache sets for each input) but the key here was making the test asynchronous by adding the |
From @youtogod in the comments of JedWatson#2012: > Add this would be better : `this.setState({ isLoading: false, options: cache[inputValue] });`. Otherwise when hitting the cache during a promise, the loading icon will remain and the menu won't appear.
Hey @JedWatson ! Was wondering if you plan to cut a new release any time soon? This feature would be valuable for my use case 🙂 (Additionally, I filed this follow-up based on @youtogod 's suggestion: #2042. Thanks!) |
Addresses #2009.
There is a WIP test -- I can't figure out how to simulate the exact
scenario that this patch fixes in the test. The current test returns
positive even without my change. Suggestions would be appreciated --
thanks!