我有' func1'包裹异步' func2'喜欢:
func1 = function(arg1) {
func2 (arg1, function(result) {
// parse and return some parts of 'result'
}, function(error) {
alert (error.message);
})
}
如何制作' func1'也是异步(对于外部代码)。
答案 0 :(得分:1)
function wrapper(callback) {//async callback is the standard for most libs
func1(arg1);//call that original func1 you defined.
callback(); //first arg is error, second is result (you don't have any result so it is empty)
}