(no title)
tonyle | 9 years ago
I mean if I didn't have the option of using promises, I would have probably written something like this.
function handler(callback){
var state={};
function logic(step,err,data){
if(!step){
connectToDb("somedatabase",logic.bind(state,1))
}
if(step==1){
if(err) callback("error1")
state.dbInstance=data
state.dbInstance.query("someQuery",logic.bind(state,2))
}
if(step==2){
if(err) callback("error2")
csvExporter(data,logic.bind(state,3))
}
if(step==3){
if(err) callback("error3")
callback(data)
}
}
logic()
}
sleazebreeze|9 years ago
xyzzy123|9 years ago
angersock|9 years ago
I think the example and your reply neatly illustrate the problem.
unknown|9 years ago
[deleted]