Skip to content

Commit

Permalink
Reset the active state once the callback runs
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Garcia committed Feb 12, 2017
1 parent 20de60f commit fecb209
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/debounce.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
setConfig(asyncModule, cb) {
this._asyncModule = asyncModule;
this._callback = cb;
this._timer = this._asyncModule.run(this._callback);
this._timer = this._asyncModule.run(this.flush);
},

/**
Expand Down
11 changes: 11 additions & 0 deletions test/unit/debounce.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@
});
});

test('flush debouncer', function(done) {
var callback = sinon.spy();
var job = Polymer.Debouncer.debounce(null, Polymer.Async.microTask, callback);

setTimeout(function() {
job.flush();
assert.isTrue(callback.calledOnce, 'callback should be called once');
done();
});
});

test('different debouncers and multiple micro tasks', function(done) {
var callback = sinon.spy();
var job1 = Polymer.Debouncer.debounce(null, Polymer.Async.microTask, callback);
Expand Down

0 comments on commit fecb209

Please sign in to comment.