Guest User

Untitled

a guest
Jul 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. setSearch: function(event) {
  2. var timer = window.setTimeout( function() {
  3. // run function here
  4. alert('fired');
  5. }, 500);
  6. },
  7.  
  8. setSearch: function(event) {
  9. var self = this;
  10. if(self.timer)
  11. clearTimeout(self.timer);
  12. self.timer = setTimeout(function() {
  13. alert('fired');
  14. self.timer = null;
  15. }, 500);
  16. }
  17.  
  18. setSearch: _.throttle(function() {
  19. //Do Stuff
  20. }, 500),
  21.  
  22. setSearch: function( ) {
  23. var firedRecently = false;
  24. return function(event) {
  25. if (firedRecently) {
  26. // it has fired recently. Do you want to do something here?
  27. } else {
  28. // not fired recently
  29. firedRecently = true;
  30. // run your function here
  31. alert('fired');
  32. var resetStatus = window.setTimeout( function () {
  33. firedRecently = false;
  34. }, 500);
  35. }
  36. }
  37. }( );
Add Comment
Please, Sign In to add comment