Skip to content

Instantly share code, notes, and snippets.

@rainder
Last active November 22, 2017 16:50
Show Gist options
  • Save rainder/d02d52cb1eeda67aa6cf to your computer and use it in GitHub Desktop.
Save rainder/d02d52cb1eeda67aa6cf to your computer and use it in GitHub Desktop.
Q = require 'q'
DeferredFnStack = (action) ->
stack = Q.when()
return ->
dfd = Q.defer()
stack = stack.fin -> Q.when(action()).then(dfd.resolve, dfd.reject)
dfd.promise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment