-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(search): add debounce on autocompletion (#135)
- Loading branch information
Showing
2 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright (c) Institut national de l'information géographique et forestière | ||
* | ||
* This program and the accompanying materials are made available under the terms of the GPL License, Version 3.0. | ||
*/ | ||
|
||
/** | ||
* Fonctions utilitaires | ||
*/ | ||
let jsUtils = { | ||
// see https://grafikart.fr/tutoriels/debounce-throttle-642 | ||
debounce(callback, delay) { | ||
var timer; | ||
return function() { | ||
console.log(delay); | ||
var args = arguments; | ||
var context = this; | ||
clearTimeout(timer); | ||
timer = setTimeout( function(){ | ||
callback.apply(context, args); | ||
}, delay); | ||
}; | ||
} | ||
}; | ||
|
||
export default jsUtils; |