Created
September 12, 2011 07:24
-
-
Save michaelsbradleyjr/1210750 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var EventEmitter = require('events').EventEmitter | |
var continuation = new EventEmitter() | |
var i = 1 | |
var end = 1000 | |
var doThisManyTimes = function () { | |
someAsyncFacilityYoureUsing(arg1, arg2 ..., function callback() { | |
continuation.emit('continue') | |
}) | |
} | |
continuation.on('continue', function () { | |
if (i++ < end) { | |
doThisManyTime() | |
} | |
}) | |
doThisManyTimes() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment