@mui/x-tree-view
Version:
The community edition of the MUI X Tree View components.
46 lines (43 loc) • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TimeoutManager = void 0;
class TimeoutManager {
timeoutIds = new Map();
intervalIds = new Map();
startTimeout = (key, delay, fn) => {
this.clearTimeout(key);
const id = setTimeout(() => {
this.timeoutIds.delete(key);
fn();
}, delay); /* Node.js types are enabled in development */
this.timeoutIds.set(key, id);
};
startInterval = (key, delay, fn) => {
this.clearTimeout(key);
const id = setInterval(fn, delay); /* Node.js types are enabled in development */
this.intervalIds.set(key, id);
};
clearTimeout = key => {
const id = this.timeoutIds.get(key);
if (id != null) {
clearTimeout(id);
this.timeoutIds.delete(key);
}
};
clearInterval = key => {
const id = this.intervalIds.get(key);
if (id != null) {
clearInterval(id);
this.intervalIds.delete(key);
}
};
clearAll = () => {
this.timeoutIds.forEach(clearTimeout);
this.timeoutIds.clear();
this.intervalIds.forEach(clearInterval);
this.intervalIds.clear();
};
}
exports.TimeoutManager = TimeoutManager;