Preparing search index...

    Function setTimeout

    • Sets a timeout to call the provided callback after the specified number of milliseconds. The callback is invoked on the scripting thread once the deadline has passed. Use clearTimeout with the returned TimeoutID to cancel a pending timeout before it fires.

      Parameters

      • code: () => void
      • delay: number

      Returns number

      TimeoutID that can be used to clear the timeout.

      Lens Scripting Version 364

      const timeoutId = setTimeout(function() {
      print("One second has passed.");
      }, 1000);

      // Cancel the timeout before it fires:
      clearTimeout(timeoutId);
    • Schedules execution of a one-time callback after delay milliseconds.

      The callback will likely not be invoked in precisely delay milliseconds. Node.js makes no guarantees about the exact timing of when callbacks will fire, nor of their ordering. The callback will be called as close as possible to the time specified.

      When delay is larger than 2147483647 or less than 1, the delay will be set to 1. Non-integer delays are truncated to an integer.

      If callback is not a function, a TypeError will be thrown.

      This method has a custom variant for promises that is available using timersPromises.setTimeout().

      Type Parameters

      • TArgs extends any[]

      Parameters

      • callback: (...args: TArgs) => void

        The function to call when the timer elapses.

      • Optionalms: number
      • ...args: TArgs

        Optional arguments to pass when the callback is called.

      Returns Timeout

      for use with clearTimeout

      v0.0.1

    • Sets a timeout to call the provided callback after the specified number of milliseconds. The callback is invoked on the scripting thread once the deadline has passed. Use clearTimeout with the returned TimeoutID to cancel a pending timeout before it fires.

      Parameters

      • callback: (args: void) => void
      • Optionalms: number

      Returns Timeout

      TimeoutID that can be used to clear the timeout.

      Lens Scripting Version 364

      const timeoutId = setTimeout(function() {
      print("One second has passed.");
      }, 1000);

      // Cancel the timeout before it fires:
      clearTimeout(timeoutId);