Debounce function with args underscore

后端 未结 4 1607
离开以前
离开以前 2021-01-31 06:51

I\'ve got a function which takes in some arguments. But usage of underscore debounce is :

var lazyLayout = _.debounce(calculateLayout, 300);

Bu

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-31 07:38

    Since nobody has written the one liner without extra var and function, I'll do it myself:

    _.debounce(calculateLayout, 300)(a, b);
    

    Debounce function returns another function, so you can call it just afterwards debounce is executed.

提交回复
热议问题