JSFiddle - React, Tailwind, and code Playground
by belorion
JavaScript
var AfterDelay = (function () {
var afterDelay = function () {
var self = this;
var pending = {};
this.queue = function (action, delay) {
if (action in pending) {
clearTimeout(pending[action]);
}
pending[action] = setTimeout(function () {
action.call(self);
delete pending[action];
}, delay);
};
};
return new queueAction();
})();
AfterDelay.queue(function(){ console.log('fired'); }, 2000)