Flipboard / Flipboard/GoldenGate

How to call method with JS callback

Open
#6 7 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
119
Forks
16
PR merge metrics
No merged PRs in 30d

Description

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 = "

Fetched:

"+data+"
";
```

If yes, could I ask how to define the callback in interface?

```
@Method("instanceOfLibrary.fetch")
void fetch(String url, ???? , Callback callback);
```

Thank you in advance for any hint!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.