Wagtail client-side components
    Preparing search index...

    Function setOptionalInterval

    • Like setInterval, but only sets the interval if the delay value is positive.

      Browsers treat non-positive delay values as 0, which means the interval will run immediately (basically all the time). Instead of allowing this behavior, this function will not set the interval instead. This allows the interval to be disabled by setting the delay value to <= 0 (or a large enough value that it overflows to negative), which is useful for user-configurable intervals.

      Parameters

      • func: TimerHandler

        the callback function to call

      • Optionaldelay: number

        the interval delay in milliseconds

      • ...args: any[]

        the arguments to pass to the callback function

      Returns null | number

      the interval ID if the interval is valid, otherwise null