debounce-promise

the doc is really not clear.

https://www.npmjs.com/package/debounce-promise

https://npm.runkit.com/debounce-promise

while truely, it turns out the debounce action needs to be PRE defined and evaluated.

so only the function is pre-defined like this will work

const preDefined = debounce((num)=> console.log("whatever action here", num), 100);
   [1, 2, 3, 4].forEach(num => {
     preDefined(num);
     });

"whatever action here"
4

while calling debounce() directly, simply like direct method calls

  [1, 2, 3, 4].forEach(num => {
    debounce(console.log("always defining", num), 100);
    });

"always defining"
1
"always defining"
2
"always defining"
3
"always defining"
4

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s