Skip to content Skip to sidebar Skip to footer

JsInterop Wrapping A Javascript Function Property

I am working with GWT 2.8, and I am working on a wrapper for a javascript library. One of the properties of a javascript class I am trying to wrap is a function. I would like the

Solution 1:

As Adam said (and explained in more detail in the other post), you can expose a @JsProperty with a @JsFunction type.

@JsType(isNative=true) public class Foo {
    @JsFunction public static interface BarFn {
        Object invoke(Object... args);
    }
    @JsProperty public BarFn bar;
}

My recommendation to learn JsInterop is to explore other projects like: OpenLayers JsInterop wrapper, Elemental2 source code, or explore github. Elemental2 has the whole browser API so there are plety of examples, it is a really good place to find examples. JsInterop documentation here.


Post a Comment for "JsInterop Wrapping A Javascript Function Property"