Skip to content

Instantly share code, notes, and snippets.

@kivi
Created September 6, 2012 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kivi/3658339 to your computer and use it in GitHub Desktop.
Save kivi/3658339 to your computer and use it in GitHub Desktop.
callback_recursion
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