tribute icon indicating copy to clipboard operation
tribute copied to clipboard

Delay for search on typing when loading remote data from backend

Open alfredalfie123 opened this issue 5 years ago • 3 comments

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.

alfredalfie123 avatar Aug 11 '18 04:08 alfredalfie123

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;
                },
            };

AshMcConnell avatar Nov 20 '18 08:11 AshMcConnell

This doesn't work, any debounce is completely ignored here.

dessalines avatar Apr 27 '22 20:04 dessalines

Figured it out!

values: debounce(async (text: string, cb: any) => {
  cb(await myAsyncFunction(text));                                                                               
}),

dessalines avatar Apr 27 '22 20:04 dessalines