调度:反弹预期功能(dispatch: debounce expects a function)

编程入门 行业动态 更新时间:2024-10-26 09:20:42
调度:反弹预期功能(dispatch: debounce expects a function)

我正在尝试消除派遣。 这里是我写的代码:

_.debounce(dispatch(_save(arr)),200)

但它不起作用。 控制台说debounce期望一个函数,是不是一个函数的dispatch ?

I'm trying to debounce a dispatch. Here is code i wrote:

_.debounce(dispatch(_save(arr)),200)

But it doesn't work. The console says that debounce expects a function, isn't a dispatch a function?

最满意答案

当它表示它期望一个函数意味着它期望一个函数引用而不是一个将返回一个值的函数调用。

所以在你的例子中它应该像A(B)而不是A(B())

funtion A(){ // some stuff } funtion B(){ //some other stuff }

或者在另一种情况下它可能是这样的:

function A(){ // some stuff } function B(){ // some stuff return C; } function C(){ // some stuff }

所以现在A(B())将是有效的,因为B()返回函数

When it says it expects a function means it expect a function reference not a function call which will return a value.

So in your example it should be like A(B) not A(B())

funtion A(){ // some stuff } funtion B(){ //some other stuff }

or maybe in another scenario it will be something like this:

function A(){ // some stuff } function B(){ // some stuff return C; } function C(){ // some stuff }

So now A(B()) would be valid cause B() returns function

更多推荐

本文发布于:2023-07-26 19:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1279939.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:功能   dispatch   debounce   expects   function

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!