Skip to content

Commit

Permalink
fix use of throttle in _emitModified to ensure autoWatchBatchDelay
Browse files Browse the repository at this point in the history
  • Loading branch information
Merott committed Aug 3, 2015
1 parent 69cd909 commit 29835e0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/file-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ var List = function (patterns, excludes, emitter, preprocess, batchInterval) {
// Emit the `file_list_modified` event.
// This function is throttled to the value of `batchInterval`
// to avoid spamming the listener.
this._emitModified = _.throttle(function () {
self._emitter.emit('file_list_modified', self.files)
}, this._batchInterval)
this._emitModified = function() {
// first time, it will emit immediately.
self._emitter.emit('file_list_modified', self.files);

// in future, it will only emit once in every _batchInterval
self._emitModified = _.throttle(function () {
self._emitter.emit('file_list_modified', self.files)
}, self._batchInterval, {leading: false});
}
}

// Private Interface
Expand Down

0 comments on commit 29835e0

Please sign in to comment.