mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
move autobind and debouncePromise to common/utils (#1081)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
78f6f8ef54
commit
770c6b80f1
8 files changed
+35
-31
No files matched your search
Executable
+9
@@ -0,0 +1,9 @@
|
||||
// Debouncing promise evaluation
|
||||
|
||||
export function debouncePromise<T, F extends any[]>(func: (...args: F) => T | Promise<T>, timeout = 0): (...args: F) => Promise<T> {
|
||||
let timer: NodeJS.Timeout;
|
||||
return (...params: any[]) => new Promise((resolve, reject) => {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => resolve(func.apply(this, params)), timeout);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user