introduce debounce on output updates + linked box
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import { executeDrawQueue } from "../outputframe-app/injects/dom-helpers";
|
||||
|
||||
export function createScript(value: string) {
|
||||
var script: HTMLScriptElement = document.createElement("script");
|
||||
script.setAttribute("async", "");
|
||||
script.innerHTML = value;
|
||||
|
||||
document.body.appendChild(script);
|
||||
|
||||
executeDrawQueue();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
export function debounceManager(debounceTime: number): { ensureDebounce: (fn: Function) => void } {
|
||||
|
||||
var curHandle: number | null = null;
|
||||
|
||||
return {
|
||||
ensureDebounce: (fn: Function) => {
|
||||
if (curHandle != null) {
|
||||
clearInterval(curHandle);
|
||||
curHandle = null;
|
||||
}
|
||||
curHandle = setTimeout(() => {
|
||||
fn();
|
||||
}, debounceTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user