📜  lodash debounce - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:18.228000             🧑  作者: Mango

代码示例2
// Avoid costly calculations while the window size is in flux.jQuery(window).on('resize', _.debounce(calculateLayout, 150)); // Invoke `sendMail` when clicked, debouncing subsequent calls.jQuery(element).on('click', _.debounce(sendMail, 300, {  'leading': true,  'trailing': false})); // Ensure `batchLog` is invoked once after 1 second of debounced calls.var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });var source = new EventSource('/stream');jQuery(source).on('message', debounced); // Cancel the trailing debounced invocation.jQuery(window).on('popstate', debounced.cancel);