13 Matching Annotations
  1. Sep 2024
  2. Sep 2022
  3. Mar 2022
  4. Mar 2021
  5. Feb 2021
  6. Oct 2020
    1. const debounceFunc = debounce(1000, false, (num) => {    console.log('num:', num);}); // Can also be used like this, because atBegin is false by defaultconst debounceFunc = debounce(1000, (num) => {    console.log('num:', num);});
    1. Looks like the problem is that debounce defaults to waiting for 0 ms ... which is completely useless!

      It would be (and is) way to easy to omit the 2nd parameter to https://lodash.com/docs/4.17.15#debounce.

      Why is that an optional param with a default value?? It should be required!

      There must be some application where a delay of 0 is useless. https://www.geeksforgeeks.org/lodash-_-debounce-method/ alludes to / implies there may be a use:

      When the wait time is 0 and the leading option is false, then the func call is deferred until to the next tick.

      But I don't know what that use case is. For the use case / application of debouncing user input (where each character of input is delayed by at least 10 ms -- probably > 100 ms -- a delay of 0 seems utterly useless.

    1. The question about default values in general - default return function values, default parameter values, default logic for when something is missing, default logic for handling exceptions, default logic for handling the edge conditions etc.