Thanks Jens,
I didn't know about that document. Do you happen to have links in any other documents like that?On Wed, Aug 16, 2017 at 1:17 PM, Jens <jens.nehlmeier@gmail.com> wrote:
Am Mittwoch, 16. August 2017 09:24:49 UTC+2 schrieb Bill Tang:I am working on a Jsinterop wrapper for the GSAP javascript library, and I am quite new to GWT, so I have come across a few problems I am not sure how to solve.My main issue revolves around trying to wrap javascript functions into Java objects.For example, if I have a native javascript function that has a function as one of its parameters, how can I go about wrapping this functionin java?The parameter that is a JS Function should be modeled using a Java functional interface, e.g. JsFunction<In, Out> { Out exec(In input); }. Then you can use Java method references or lambdas.And if a javascript class has a function has one of its properties, how can I go about wrapping this property?Similar as above. In Java the property type would be a @JsFunction annotated interface.I've had some success using the @JsFunction annotation along with functional interfaces, but I am faced with the problemwhere I have to declare return types, parameters, and paramater types in the java interface, when I want to be able to supplyany arbitrary function, just like I would in native javascript. Is there any way to mimic this functionality?Java is strongly typed, so some JS things are not possible in Java. Do you have a concrete example? Usually JS libs have some rules to functions and which parameters they expect. If you have trouble with so called "union types" you can take a look at https://docs.google.com/document/d/14mQeAGQ9M_ to see how the jsinterop generator handles it.5uTTUbzRQzCYETA887dTO- xFLtQhgUXXk/edit -- J.--
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 .
--
Vassilis Virvilis
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