Tuesday, August 30, 2016

Re: jsinterop export method that returns Optional

Except you'd also want to add @JsFunction on Function, Predicate and Supplier to make Optional "useful"; so, no, adding @JsType on Optional is not a good idea (also note that for collections this is only on interfaces; constructors and static fields/methods are all @JsIgnore-d).

When exposing such method to JS, you should IMO return a '@Nullable T' value rather than an Optional<T>.

On Tuesday, August 30, 2016 at 3:34:09 PM UTC+2, Jens wrote:
As a workaround you can probably copy GWT's Optional emulation into your own project, add JsInterop annotations and then it should work.

GWT does not place JsInterop annotations on most JRE emulations because the compiler only has an "all-or-nothing" switch (-generatesJsInteropExports). That means all code that can be accessed from the @JsType annotated class can not be pruned because it might be called by external JS. So it would result in a final JS code size increase.

But you can make a feature request on Github, as GWT has @JsType some Collections: https://gwt-review.googlesource.com/#/c/15191/

-- 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.

No comments:

Post a Comment