@graphistry/falcor
Version:
A JavaScript library for efficient data fetching.
24 lines (19 loc) • 543 B
JavaScript
function TimeoutScheduler(delay) {
this.delay = delay;
}
var TimerDisposable = function TimerDisposable(id) {
this.id = id;
this.disposed = false;
};
TimeoutScheduler.prototype.schedule = function schedule(action) {
return new TimerDisposable(setTimeout(action, this.delay));
};
TimerDisposable.prototype.dispose =
TimerDisposable.prototype.unsubscribe = function() {
if (!this.disposed) {
clearTimeout(this.id);
this.id = null;
this.disposed = true;
}
};
module.exports = TimeoutScheduler;