17 lines
332 B
JavaScript
17 lines
332 B
JavaScript
export class KeyTimeout {
|
|
constructor() {
|
|
this.timeoutHandleForKey = {};
|
|
}
|
|
|
|
clearTimeout(key) {
|
|
clearTimeout(this.timeoutHandleForKey[key]);
|
|
}
|
|
|
|
updateTimeout(key, durationMs, callback) {
|
|
this.clearTimeout(key);
|
|
this.timeoutHandleForKey[key] = setTimeout(() => {
|
|
callback();
|
|
}, durationMs);
|
|
}
|
|
}
|