MCPcopy
hub / github.com/CapSoftware/Cap / scheduleIdleWork

Function scheduleIdleWork

apps/desktop/src/routes/editor/Editor.tsx:69–85  ·  view source on GitHub ↗
(callback: () => void)

Source from the content-addressed store, hash-verified

67const TIMELINE_RESIZE_GRIP_MARKS = [0, 1, 2] as const;
68
69const scheduleIdleWork = (callback: () => void) => {
70 const win = window as Window & {
71 requestIdleCallback?: (
72 callback: () => void,
73 options?: { timeout: number },
74 ) => number;
75 cancelIdleCallback?: (handle: number) => void;
76 };
77
78 if (win.requestIdleCallback) {
79 const handle = win.requestIdleCallback(callback, { timeout: 1_000 });
80 return () => win.cancelIdleCallback?.(handle);
81 }
82
83 const handle = window.setTimeout(callback, 250);
84 return () => window.clearTimeout(handle);
85};
86
87function getEditorErrorMessage(error: unknown) {
88 return error instanceof Error ? error.message : String(error);

Callers 1

InnerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected