tribute
tribute copied to clipboard
Delay for search on typing when loading remote data from backend
I thought currently there are no debounce/throttle support when use this library
What did you expect to happen? Tribute should support debounce input event
What happened instead? Whenever user type anything in tribute component, it keep send AJAX request to the server.
This is reasonably simple to do yourself using lodash debounce (or similar), see the values property below
const tributeOptions = {
trigger: '`',
values: _.debounce(this.loadData.bind(this), 200),
lookup: 'surname',
selectTemplate: function (item) {
return item.original.surname;
},
};
This doesn't work, any debounce is completely ignored here.
Figured it out!
values: debounce(async (text: string, cb: any) => {
cb(await myAsyncFunction(text));
}),