Forked from kimmobrunfeldt/underscore-debounce-example.js
Created
December 19, 2019 11:03
-
-
Save chringel21/311dff238f40d226fd7109e827ba4041 to your computer and use it in GitHub Desktop.
Example of using Underscore's _.debounce function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example of using Underscore's _.debounce function | |
// debounce is useful for situations where you get multiple events fired | |
// from one action. For example resize event is sent multiple times when | |
// window is resized | |
var reloadIfResizeChange = _.debounce(function() { | |
window.location.reload(); | |
}, 200); | |
window.addEventListener('resize', reloadIfResizeChange); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment