I am brand-spanking new to AngularJS and I am contributing to my first ever open source project. My first issue is that, when using the search box on the page, if you repeat a search enough times (for example, searching for mathematics and then deleting the s, retyping the s, etc), eventually the search for mathematic will return the results intended for mathematics. The search is set up to perform the search with every keyup.
You can test it out on the page here: https://www.oppia.org/
Developer tools shows that this is a timing issue where the search results for the previous request are returning before the search results for the current request.
I've looked at several questions and these two seem the most relevant:
- Angular js stop previous http request with ng-change
- In AngularJS, how to stop ongoing $http calls on query change
I've tried using the cancel promise option, but testing thus far has showed that none of the requests were, in fact, being cancelled. On looking at the other question, it seems like the debouncer should take the place of this other option, but I wasn't sure.
We're using v1.4 and we have implemented a debouncer for 400 milliseconds. My question is, is the solution simply be to make the debouncer delay longer or do I need to further investigate cancelling the previous xhr request when a new request is made?