Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

  • sleepAsync(timeMs: number): Promise<void>
  • Creates a Promise that completes after the specified number of miliseconds

    example
    await sleepAsync(3000); // returns in 3 seconds
    

    Parameters

    • timeMs: number

    Returns Promise<void>

  • waitForConditionAsync(func: () => boolean, timeoutFunc: () => void, timeoutMs?: number): Promise<void>
  • Returns a Promise that completes when the test function returns true, or after the timeout has elapsed

    example
    let test = 1;
    const trueFunc = () => {test == 1}
    const falseFunc = () => {test == 2}
    const timeoutFunc = () => {console.warn('timeout!')}
    waitForConditionAsync(trueFunc, timeoutFunc, 3000); // returns right away
    waitForConditionAsync(falseFunc, timeoutFunc, 3000); // returns in 3s and console.warn('timeout!')

    Parameters

    • func: () => boolean

      a function that returns true when the test condition is met

        • (): boolean
        • Returns boolean

    • timeoutFunc: () => void

      the function called after a timeout

        • (): void
        • Returns void

    • timeoutMs: number = 2000

      miliseconds to wait for the test function to return true before timing out

    Returns Promise<void>

  • yieldAsync(): Promise<void>
  • Asynchronous method to force the method to complete asynchronously

    example
    this.isLoading = true;
    await yieldAsync(); // makes sure this.isLoading is true, and the subsequence call is based on this.isLoading being true

    Returns Promise<void>

Generated using TypeDoc