SDFIdk / gsearch-ui

Web component that implements a simple UI for GSearch. NPM package available
https://sdfidk.github.io/gsearch-ui/
MIT License
2 stars 0 forks source link

Stop previous api calls when a new one is made #33

Open Gebuz opened 1 year ago

Gebuz commented 1 year ago

With api calls where the response time is greater than the debounce time we can start a new call before the first has arrived, resulting in the old results arriving after the new ones. Old API calls to the same resource should be stopped when a new one is made. For instance, https://api.dataforsyningen.dk/gsearch_test/v1.0/adresse?q=frederik&limit=10 currently has a response time of ~7 seconds, but https://api.dataforsyningen.dk/gsearch_test/v1.0/adresse?q=frederik%207&limit=10 is only ~1 second.

iamfrank commented 1 year ago

Det er nok et job for AbortController https://developer.mozilla.org/en-US/docs/Web/API/AbortController