Polls a resource until a terminal condition is met or timeout occurs.
Function that fetches the latest state of the resource
Function that determines if the current state is terminal
Function that transforms the resource into a new type
Configuration options for polling behavior
The resource in its terminal state
If the operation exceeds the timeout duration
const result = await wait( () => fetchOrderStatus(orderId), (status) => status === 'completed', (status) => status === 'completed' ? { status } : undefined, { timeoutSeconds: 30 }); Copy
const result = await wait( () => fetchOrderStatus(orderId), (status) => status === 'completed', (status) => status === 'completed' ? { status } : undefined, { timeoutSeconds: 30 });
Polls a resource until a terminal condition is met or timeout occurs.