@blinkk/degu
    Preparing search index...

    Function debounce

    • A basic debounce implementation. Debounce will basically wait X amount of seconds to execute AFTER it's last call.


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

      // Now when you resize, it will wait 500 ms until the last resize call.
      window.addEventListener('resize', debounce);

      Or

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

      Parameters

      • callback: Function

        The function to call.

      • wait: number

        The ms to delay.

      • Optionalimmediate: boolean

        Optional, whether to immediately run (changes this to throttle)

      Returns () => void

      A debounced function