Thursday, December 10, 2015

Re: JsInterop for setTimeout()

Oh well. Might as well point to the real code base from my work-in-progress WebIDL-to-JsInterop tool

https://github.com/rhmoller/embrace/blob/master/examples/src/main/java/com/giddyplanet/embrace/examples/client/Examples.java#L62

But beware - it is far from ready for general consumption

https://github.com/rhmoller/embrace

Hope it at least builds and runs on other machines than mine...

/Rene

Den fredag den 11. december 2015 kl. 00.03.25 UTC+1 skrev rhmoller:
Hi

I have trouble modeling WindowTimers.setTimeout() with JsInterop.

I have tried something roughly like this

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public interface WindowTimers {
  int setTimeout(Object handler, int timeout, Object... arguments);
}

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public abstract class Window WindowTimers {
}


along with a MyFunction

@JsFunction
public interface MyFunction<T> {
  void execute(T ... args);
}


and I invoke it like this

getWindow().setTimeout((MyFunction) args -> window.alert("Hello " + args[0]), 1000, "World");

I get a popup saying "Hello W" where I would expect it to say "Hello World"

best regards
Rene


--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment