kaven-basic - v6.2.0
    Preparing search index...

    Function StartTimer

    • Starts a timer that executes the provided callback function at specified intervals.

      Parameters

      • callback: () => void | Promise<void>

        The function to be executed when the timer elapses. It can be either a synchronous function that returns void or an asynchronous function that returns a Promise<void>.

      • interval: number | ITimeSpan

        The interval at which the timer should fire. It can be either a number representing the time duration or an ITimeSpan object.

      • Optionalunit: "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "weeks"

        The time unit of the interval if it's a number. Defaults to "milliseconds". This parameter is optional and is used only when interval is a number.

      • invokeImmediately: boolean = false

        When true, invokes the callback once as soon as the timer starts; when false, waits for the first interval. The immediate invocation is included in the timer's invocation count. Defaults to false.

      • scheduleNextBeforeTrigger: boolean = false

        When false, waits for the current callback (including a returned promise) to finish before scheduling the next invocation, preventing overlap. When true, schedules first to maintain the configured cadence, allowing callbacks to overlap when they run longer than the interval. Defaults to false.

      Returns Timer

      An instance of the Timer class that has been started and is set to execute the callback at the specified interval.

      4.3.0

      2026-08-17

      If invokeImmediately is enabled, scheduleNextBeforeTrigger also controls whether the invocation following the immediate callback is scheduled before or after that callback finishes.