Function setRelativeInterval

  • Sets an interval that fires at the given interval with respect to when it was fired.

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

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

    // ideal output:
    // 6555: FIRED
    // 7555: FIRED
    // 8555: FIRED
    // etc...

    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.