Waiting for the user to finish writing #615
-
Hi, I follow the guide to populate my sources with async data, which work great but there a problem. Here is my autocomplete setup : autocomplete({
container: '#autoComplete_wrapper',
placeholder: 'Chercher par nom, téléphone, email, fonction',
getSources({ query }) {
return axios(searchWrapper.dataset.searchQuery + "?query=" + query)
.then(res => {
// const formattedData = data.
return [
{
sourceId: 'Agents',
getItems() {
return res.data
},
getItemUrl({ item }) {
return item.id;
},
templates: {
item({ item }) {
return `${item.displayname} - ${item.title}`;
},
},
}
]
})
},
onStateChange({state}) {
console.log(state.status);
}
}); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey! You can debounce the promise in |
Beta Was this translation helpful? Give feedback.
Hey! You can debounce the promise in
getSources
, like we're doing in this example:autocomplete/examples/github-repositories-custom-plugin/createGitHubReposPlugin.tsx
Lines 24 to 41 in e019b4d