Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Results delivered out of order #877

Closed
bartoszhernas opened this issue Dec 13, 2019 · 1 comment
Closed

Results delivered out of order #877

bartoszhernas opened this issue Dec 13, 2019 · 1 comment

Comments

@bartoszhernas
Copy link

Is there a way to cancel a promise?

I am trying to integrate Algolia client-side search with react-select async component
https://react-select.com/async

The problem I am having is that on every input change, there is a callback being called, where I am calling

locationSearchIndex.search({query: search}).then(({hits}) => { return hits })

The problem is that, after fastly typing S F O, the results for S are delivered last, and that's what my component displays.

Before I was using AJAX call to our backend, and I was able to just cancel the promise (so the old promises never resolved).

I tried comparing the last query with the results query and throwing an exception to reject promise, but then it's treated as API error. I need a wait to clear the promise altogether.

@bartoszhernas
Copy link
Author

Issue was with debounce from lodash

JedWatson/react-select#3075 (comment)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant