Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. debounce: function(func, wait, immediate) {
  2. var timeout;
  3. return $A.getCallback(function() {
  4. var context = this,
  5. args = arguments;
  6. var later = function() {
  7. timeout = null;
  8. if (!immediate) {
  9. func.apply(context, args);
  10. }
  11. };
  12. var callNow = immediate && !timeout;
  13. clearTimeout(timeout);
  14. timeout = setTimeout(later, wait);
  15. if (callNow) {
  16. func.apply(context, args);
  17. }
  18. });
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement