Reputation: 35346
For example I have a library with this main function:
public class Xlib{
public static XRequest get(String url){
return new Xequest(url);
};
}
How can this be usable to Javascript as third-party library using preferably JsInterop method?
Upvotes: 1
Views: 117
Reputation: 357
Java:
package test;
import jsinterop.annotations.JsType;
@JsType
class XRequest{
private String url;
public XRequest(String url)
{
this.url=url;
}
public String testGet()
{
return url;
}
};
@JsType
class Xlib{
public static XRequest get(String url){
return new Xequest(url);
};
}
JS:
var xr = test.Xlib.get('stackoverflow');
xr.testGet();//return 'stackoverflow'
Upvotes: 1