Debounce function with args underscore

后端 未结 4 1605
离开以前
离开以前 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:32

    @Jamie's answer is better.

    I'll keep my original answer as below, although the it should be better to use Jamie's answer if you are familiar with JS:

    var calculateLayout = function(a,b) {
      console.log('a is ' + a + ' and b is ' + b);
    }
    
    var debounceCalculate = _.debounce(function(a, b){
        calculateLayout(a, b);
    }, 300);
    
    debounceCalculate(1, 2);
    

提交回复
热议问题