Function sleepWhile

Delays until predicate returns true. Can be useful for synchronising with other async activities.

// Delay until 'count' reaches 5
await sleepWhile(() => count >= 5, 100);
  • Parameters

    • predicate: (() => boolean)
        • (): boolean
        • Returns boolean

    • checkInterval: Interval = 100

    Returns Promise<void>