1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00
joplin/packages/app-mobile/utils/debounce.tsx

15 lines
535 B
TypeScript

import PoorManIntervals from '@joplin/lib/PoorManIntervals';
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
function debounce(func: (...args: any[])=> void, timeout: number) {
let timer: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
return (...args: any[]) => {
PoorManIntervals.clearTimeout(timer);
timer = PoorManIntervals.setTimeout(() => { func.apply(this, args); }, timeout);
};
}
export default debounce;