Function setAbsoluteInterval

  • Sets an interval that fires at the given interval with respect to timestamp 0.

    const start = Date.now(); // 5555

    // interval fires every second
    setAbsoluteInterval(()=>{
    const now = Date.now();
    console.log(`${now}: FIRED`);
    }, 1000);

    // ideal output:
    // 6000: FIRED
    // 7000: FIRED
    // 8000: FIRED
    // etc...

    The first time the interval fires, the delay can vary wildly. If you set it at timestamp ###999, it will want to fire after 1 millisecond. If you set it at timestamp ###001, it will want to fire after 999 milliseconds.

    Parameters

    • callback: CustomIntervalCallback

      A callback that is fired on the interval.

    • interval: number

      The interval to fire the callback at.

    Returns number

    An ID that tracks this interval.