调度:反弹预期功能(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
更多推荐
发布评论