@blinkk/degu
    Preparing search index...

    Function throttle

    • Throttles a function. Throttle will run a function immediately when it's called and wait X amount of seconds before it can be called again.


      const throttler = func.throttle((windowEvent)=> {
      console.log(wiindowEvent);
      }, 500);

      // Now when you resize, it will immediately call the throttle function
      // and wait 500 ms before it can be called again.
      window.addEventListener('resize', throttler);

      Or just:

      window.addEventListener('resize', func.throttle(()=> {
      console.log('throttled');
      }, 500))

      Parameters

      • callback: Function

        The callback function

      • wait: number

        The amount to wait in ms.

      Returns () => void