How to use the debounce function from underscore

Find comprehensive JavaScript underscore.debounce code examples handpicked from public code repositorys.

966
967
968
969
970
971
972
973
974
975

// Returns a function, that, when invoked, will only be triggered at most once
// during a given window of time.
_.throttle = function(func, wait) {
  var context, args, timeout, throttling, more;
  var whenDone = _.debounce(function(){ more = throttling = false; }, wait);
  return function() {
    context = this; args = arguments;
    var later = function() {
      timeout = null;
fork icon0
star icon0
watch icon1

+ 6 other calls in file

119
120
121
122
123
124
125
126
127
128
  this.dropdownView.setCloseCallback(this.clearInput.bind(this, true));
  $(document.body).click(this.clearInput.bind(this, false));
  this.selectionView.on("clear", this.deselectTopLevelItemModel.bind(this));
  this.suggestions = [];

  this.$el.on("keyup", "input.search", Underscore.debounce( this.searchImmediatelyIfNeeded.bind(this), 200));
  return this;
},

addSuggestionToPlaceholder: function (suggestion) {
fork icon0
star icon0
watch icon1

+ 5 other calls in file