Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@michiel michiel commented May 18, 2011

Functions can be inlined as follows,

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

This comment has been minimized.

Copy link
Owner Author

@michiel 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