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

Function waitFor

packages/vue-db/tests/useLiveQuery.test.ts:86–99  ·  view source on GitHub ↗
(fn: () => void, timeout = 2000, interval = 20)

Source from the content-addressed store, hash-verified

84
85// Helper function to poll for a condition until it passes or times out
86async function waitFor(fn: () => void, timeout = 2000, interval = 20) {
87 const start = Date.now()
88
89 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
90 while (true) {
91 try {
92 fn()
93 return
94 } catch (err) {
95 if (Date.now() - start > timeout) throw err
96 await new Promise((resolve) => setTimeout(resolve, interval))
97 }
98 }
99}
100
101describe(`Query Collections`, () => {
102 it(`should work with basic collection and select`, async () => {

Calls 1

fnFunction · 0.85

Tested by

no test coverage detected