Skip to content

Commit

Permalink
Add debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
yangshun committed Jan 13, 2018
1 parent 8120da4 commit d0fdd02
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions utilities/debounce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const debounce = (fn, time) => {
let timerId;
return function(...args) {
const functionCall = () => fn.apply(this, args);
clearTimeout(timerId);
timerId = setTimeout(functionCall, time);
};
};

0 comments on commit d0fdd02

Please sign in to comment.