For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/lynx-api/global/set-interval.md.
Lynx
  • English
  • setInterval() global function

    Repeatedly calls a function or executes a code fragment with a fixed time interval between each call.

    Syntax

    setInterval(function: () => void, delay: number): number;

    Parameters

    function

    Functions to be called repeatedly are executed after every specified delay milliseconds. The first call occurs after delay milliseconds.

    delay

    The time interval between repeated function calls, in milliseconds.

    The js thread may be frozen while the app is in the background. Therefore, the actual delay of setInterval may be greater than the specified value. At the same time, the duration of the js thread being frozen will still be counted in the delay of setInterval. In this case, the specified function will only be called once immediately after the app wakes up, even if the js thread is frozen for a number of times longer than delay.

    Return value

    Returns a positive integer representing the ID value of the timer. This ID value can be used to cancel the timer.

    The front-end code should not make any assumptions about the actual value of the returned ID.

    Example

    Compatibility

    LCD tables only load in the browser

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.