Async> cache async response regardless of req order#2012
Merged
JedWatson merged 2 commits intoJedWatson:masterfrom Sep 21, 2017
Merged
Async> cache async response regardless of req order#2012JedWatson merged 2 commits intoJedWatson:masterfrom
JedWatson merged 2 commits intoJedWatson:masterfrom
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.
Owner
|
Thanks @timhwang21 This looks good to merge, I'll see what I can do to get the test working |
Owner
|
@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 |
timhwang21
added a commit
to timhwang21/react-select
that referenced
this pull request
Oct 8, 2017
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.
Contributor
Author
|
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!) |
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.
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!