Javascript Promise Object With Gwt Jsinterop
I have this code that I want to use to init() a third-party Javascript library: @JsType(namespace = JsPackage.GLOBAL, name = 'Kinvey', isNative = true) public class Kinvey { pu
Solution 1:
This example is use to return JS promises from GWT code, but you can adapt it for your scenario, it just wraps the Promise
Javascript class with its Java counterpart class, declaring also then()
and catch()
methods:
@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public class Promise {
@JsFunction
public interface FunctionParam {
void exec(Object o);
}
@JsFunction
public interface ConstructorParam {
void exec(FunctionParam resolve, FunctionParam reject);
}
@JsConstructor
public Promise(ConstructorParam parameters) {
}
public Promise then(FunctionParam f) { }
public Promise catch(FunctionParam f) { }
}
Post a Comment for "Javascript Promise Object With Gwt Jsinterop"