Sunday, December 13, 2015

Re: JsInterop for setTimeout()

Noticed the commit message in changeset https://gwt.googlesource.com/gwt/+/fe3aaefe5427b35534cc2bf139e9e882009ed809

So I guess this is a known missing feature at the moment.

/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 https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment