-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
feat: Timeout before calling autocomplete #8790
feat: Timeout before calling autocomplete #8790
Conversation
9540b4b
to
969f539
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
|
||
debounceTimer = setTimeout(function(){ | ||
// https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort | ||
if (abortController) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we do the abort before the setTimeout? i.e. when the user types something, we cancel the previous request immediately, and then we issue the request after 300ms? Otherwise we could get back suggestions that don't match all the letters we typed.
Good idea I think, I will test it. |
Seems to work quite well. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
What
As users are writing into Tagified content that performs autocompletion, each letter typed will result in an immediate call to API.
This amounts of requests and cancellations may overload the API service, which in turn cause that lookup takes long (+5 seconds to get response).
In order to improve this situation:
timeout
starts.timeout
will restart from beginning.timeout
completes, the REST API call will be executed.NOTE: This code is not tested. Feel free to make any additional changes required.
Part of