Hi,
is possible to call method with JS callback?
Example:
Library.prototype.fetch = function(url,cb,scope) {
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (request.readyState==4 && request.status==200) {
cb.call(scope,request.responseText);
}
}
request.open("GET",url,true);
request.send();
}
In JS call looks like this:
instanceOfLibrary.fetch('_URL_', function(data) {document.getElementById("output").innerHTML = "<h2>Fetched:</h2><pre>"+data+"</pre>";
If yes, could I ask how to define the callback in interface?
@Method("instanceOfLibrary.fetch")
void fetch(String url, ???? , Callback<String> callback);
Thank you in advance for any hint!
Hi,
is possible to call method with JS callback?
Example:
In JS call looks like this:
If yes, could I ask how to define the callback in interface?
Thank you in advance for any hint!