Created
May 29, 2013 15:04
-
-
Save hikarock/5670990 to your computer and use it in GitHub Desktop.
_.debounce
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
* { | |
margin: 0; | |
padding: 0; | |
border: 0; | |
} | |
body { | |
background: #dff; | |
font: 30px sans-serif; | |
} |
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
<button>save</button> |
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
var delay = 10 * 1000; | |
var save = _.debounce(function() { | |
console.log("wait end"); | |
// 超重い保存処理 | |
}, delay); | |
function handler() { | |
console.log("wait start"); | |
save(); | |
} | |
$("button").on("click", handler); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment