Skip to content

Instantly share code, notes, and snippets.

@michiel
Created May 17, 2011 13:33
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 michiel/976470 to your computer and use it in GitHub Desktop.
Save michiel/976470 to your computer and use it in GitHub Desktop.
Sequencer in coffeescript
sequence = (arr) ->
self = ->
if arr.length then arr.shift() self
self()
async = (callback) ->
console.log "Calling callback after 1s"
setTimeout callback, 1000
sequence [async, async, async]
@michiel
Copy link
Author

michiel commented May 18, 2011

Functions can be inlined as follows,

    async = (callback) ->
      setTimeout () ->
          console.log "Calling callback after 1s"
          callback()
        , 1000 

@michiel
Copy link
Author

michiel commented May 23, 2011

See https://github.com/michiel/sequencer-js for some background.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment