waitFor()
function waitFor(condition: () => boolean, options: WaitForOptions): Promise<void>;Defined in: src/lib/utils.ts:76
Wait for a condition to become true with timeout.
Polls the condition function until it returns true, or throws an error if the timeout is exceeded.
Parameters
| Parameter | Type | Description |
|---|---|---|
condition | () => boolean | Function that returns true when the wait should end. |
options | WaitForOptions | Configuration options. |
Returns
Promise<void>
A promise that resolves when the condition is met.
Throws
Error if the timeout is exceeded.
Example
// Wait for model to load
await waitFor(() => HasModelLoaded(modelHash), {
timeout: 5000,
timeoutMessage: "Model failed to load"
});
// Wait with custom interval
await waitFor(() => someCondition(), { interval: 100 });