Answer the question
In order to leave comments, you need to log in
How to get response from asynchronous function?
function AppCreate(data) {
window.WebViewJavascriptBridge.callHandler('create', data, function(response) {
return response
})
}
Answer the question
In order to leave comments, you need to log in
Well, the best thing is to use callback.
function AppCreate(data, callback) {
window.WebViewJavascriptBridge.callHandler('create', data, function(response) {
callback(response);
return response;
})
}
AppCreate(data, function(response){
// здесь что-то делать с response
});
function AppCreate(data) {
var deferred = Q.defer();
window.WebViewJavascriptBridge.callHandler('create', data, function(response) {
deferred.resolve(data);
});
return response;
}
AppCreate(data).then(function(response){
// здесь что-то делать с response
});
If the function is asynchronous, then you won’t be able to get the value except through callbacks, and promises are also a kind of callbacks, only implemented in a more convenient way
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question