Function SetInterval

  • Continuously calls the callback function every interval seconds.

    Parameters

    • interval: number

      Seconds between calls.

    • callback: Callback

      Function to be called.

    • Optional immediate: boolean

      Whether or not to call the callback immediately, rather than wait for the first interval (default false).

    Returns (() => void)

    Cancellation function.

    const cancel = SetInterval(1, () => {
    print("This code runs every 1 second");
    });

    // Optionally call the cancel function stop the loop:
    cancel();
      • (): void
      • Returns void