Created
September 6, 2012 16:42
-
-
Save kivi/3658339 to your computer and use it in GitHub Desktop.
callback_recursion
This file contains 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
windows = [1,2,3] | |
work_with = (value) -> | |
console.log "VALUE: #{value}" | |
do_array = (my_array, callback) -> | |
if my_array.length > 0 | |
work_with my_array.shift() | |
setTimeout( () -> | |
do_array my_array, callback | |
, 1000) | |
else | |
callback() | |
main_code = -> | |
console.log "start" | |
do_array windows, -> | |
console.log "finish poping" | |
console.log "end of main_code" | |
main_code() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment