setTimeout refactoring
This commit is contained in:
parent
559033f0a6
commit
067c26982e
@ -331,14 +331,15 @@ const yomichan = (() => {
|
|||||||
if (timeout !== null) {
|
if (timeout !== null) {
|
||||||
timeoutId = window.setTimeout(() => {
|
timeoutId = window.setTimeout(() => {
|
||||||
timeoutId = null;
|
timeoutId = null;
|
||||||
reject(new Error(`Listener timed out in ${timeout} ms`));
|
|
||||||
eventHandler.removeListener(runtimeMessageCallback);
|
eventHandler.removeListener(runtimeMessageCallback);
|
||||||
|
reject(new Error(`Listener timed out in ${timeout} ms`));
|
||||||
}, timeout);
|
}, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
const cleanupResolve = (value) => {
|
const cleanupResolve = (value) => {
|
||||||
if (timeoutId !== null) {
|
if (timeoutId !== null) {
|
||||||
window.clearTimeout(timeoutId);
|
window.clearTimeout(timeoutId);
|
||||||
|
timeoutId = null;
|
||||||
}
|
}
|
||||||
eventHandler.removeListener(runtimeMessageCallback);
|
eventHandler.removeListener(runtimeMessageCallback);
|
||||||
sendResponse();
|
sendResponse();
|
||||||
|
Loading…
Reference in New Issue
Block a user