I created my own custom array in JsInterop:
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Array")
public interface Array<T>
{
public void push(T value);
@JsProperty(name = "length")
public int getLength();
@JsProperty(name = "length")
void setLength(int newLength);
@JsOverlay
default T get(int index) {
return JsArrayHelper.getArrayValue(this, index);
}
}
And here is the JsArrayHelper class scaled down:
public class JsArrayHelper
{
//TODO: Eliminate JSNI. Better way to do this?
public static native <T> T getArrayValue(Array<T> a, int i) /*-{
return a[i];
}-*/;
}
Is there a better way to get the value of the array instead of using JSNI?