Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

loadsh debounce

// 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);
Source by lodash.com #
 
PREVIOUS NEXT
Tagged: #loadsh #debounce
ADD COMMENT
Topic
Name
1+1 =