-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Async suggestions #757
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
Async suggestions #757
Conversation
I had to change the sprite loader because it didn't worked after enabling |
Hi, is this being merged soon? I'm trying to fetch suggestions from an API endpoint like so:
But it doesn't resolve and instead just returns a Promise. I'm assuming async will solve this? |
We do our best to get through the backlog of PRs and issues in all related repositories, but give us some time, especially for things that lead to breaking changes. 😬 |
Oh of course, I totally understand. Please take your time. Thank you for the response! |
Hi, any update? :) |
Thanks @Chrissi2812! 🙌 |
Would we be able to get a working example of async data? I've left the items array empty and am fetching the users from an API endpoint:
The data being returned from the endpoint is in the exact same format as the examples, but it doesn't get loaded into the popup. It just says "No users found". |
Solved using this code in the onFilter method:
|
I have a quick question regarding this feature, How would you go about debouncing the request? Since a request is made on every query change, I'd like to debounce it for at least 500ms so the user isn't spamming the api while typing. Thanks |
Try to wrap it in an async debounce function: https://www.npmjs.com/package/debounce-async Hope that helps! |
Sweet! worked like a charm, Thanks! new Mention({
...
onFilter: debounce(this.onFilter.bind(this), 500),
...
}) |
This allows to use async functions for
items
andonFilter
.Keep in mind first the items will get loaded an then the
onFilter
will run over them.So maybe use an empty
items
array and query your backend in theonFilter
function.Little Example:
Possible Breaking Change
onFilter
anditems
function are not calledonExit
.Otherwise the
onExit
callback would be delayed until both other functions are finished.Fix #755