Stoplight
A simple flow control mechanism.
Has two modes: "go" and "stop".
Starts stopped.
var stoplight = new Stoplight()
stoplight.await(function(){
})
stoplight.go()
Example
Here is a class that has some async intialization process,
but can have its asynchronous method called immediately w/o breaking.
function MyClass() {
var self = this
self._stoplight = new Stoplight()
asyncInitialization(function(){
self._stoplight.go()
})
}
MyClass.prototype.asyncMethod = function(cb){
var self = this
self._stoplight.await(function(){
})
}