繁体   English   中英

有人可以解释一下这个例子中的功能流程吗?

[英]Can someone explain me the flow of functions in this example?

多个回调

我查看了上面的代码,并尽力寻找解决方案,并在全力以赴后将其发布在这里。 This is my current understanding of the code: debounce() is called when there is an input and onInput() is passed to it as a callback, and debounce function return another function, the function being returned takes an argument which is the function passed通过 debounce() aka onInput(),我被卡住了 @ func.apply(null, args); 1.func和args不是一回事吗??? 有人请逐步解释是可能的..

这是一个去抖动的例子。

  • 去抖动是一种用于提高浏览器性能的做法。
  • 一种编程实践,可确保耗时的任务不会如此频繁地触发。
  • 它用于限制调用 function 的速率。

我已经用例子解释了 debounce,请查看链接debounce

debouce仅在初始运行时调用一次,它创建并返回一个新的匿名 function - 实际的事件处理程序。

当输入事件被触发时,之前创建的function会被执行,并会在500ms后调用func (onInput)。 func只传递给 debounce 一次,但args是实际的输入事件 arguments,它将通过apply传递给func 在这种情况下,apply 与func(...args);基本相同。 因此func (又名 onInput)将在 500 毫秒后使用来自输入事件的实际 arguments 调用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM