MCPcopy Create free account
hub / github.com/TanStack/db / waitUntil

Function waitUntil

packages/offline-transactions/tests/storage-failure.test.ts:10–23  ·  view source on GitHub ↗
(
  predicate: () => boolean | Promise<boolean>,
  timeoutMs = 5000,
  intervalMs = 20,
)

Source from the content-addressed store, hash-verified

8import type { OfflineConfig, StorageDiagnostic } from '../src/types'
9
10const waitUntil = async (
11 predicate: () => boolean | Promise<boolean>,
12 timeoutMs = 5000,
13 intervalMs = 20,
14) => {
15 const deadline = Date.now() + timeoutMs
16 while (Date.now() < deadline) {
17 if (await predicate()) {
18 return
19 }
20 await new Promise((resolve) => setTimeout(resolve, intervalMs))
21 }
22 throw new Error(`Timed out waiting for condition`)
23}
24
25describe(`storage failure handling`, () => {
26 let mockCollection: any

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected