MCPcopy
hub / github.com/marimo-team/marimo / waitForCondition

Function waitForCondition

frontend/src/core/islands/__tests__/test-utils.tsx:112–124  ·  view source on GitHub ↗
(
  condition: () => boolean,
  timeout = 1000,
  interval = 50,
)

Source from the content-addressed store, hash-verified

110 * Waits for a condition to be true with timeout
111 */
112export async function waitForCondition(
113 condition: () => boolean,
114 timeout = 1000,
115 interval = 50,
116): Promise<void> {
117 const startTime = Date.now();
118 while (!condition()) {
119 if (Date.now() - startTime > timeout) {
120 throw new Error("Timeout waiting for condition");
121 }
122 await new Promise((resolve) => setTimeout(resolve, interval));
123 }
124}
125
126/**
127 * Waits for an async function to not throw

Callers

nothing calls this directly

Calls 1

nowMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…