Why not make a polyfill on the native js array loaded with the gwt runtime (dynamically adding needed functions on it) so that it conforms to the Java array type? Would be ok to do that 99%of the time I think. It would simplify so much interoperability between them, IMHO... Arnaud
Le jeu. 3 août 2017 à 12:50, < [email protected]> a écrit : > [email protected] > <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/google-web-toolkit-contributors/topics> > Google > Groups > <https://groups.google.com/forum/?utm_source=digest&utm_medium=email/#!overview> > <https://groups.google.com/forum/?utm_source=digest&utm_medium=email/#!overview> > Topic digest > View all topics > <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/google-web-toolkit-contributors/topics> > > - NodeList and JsArrayList.asArray > <#m_-6068370991899046413_group_thread_0> - 3 Updates > > NodeList and JsArrayList.asArray > <http://groups.google.com/group/google-web-toolkit-contributors/t/9a0b1ab8b5df74bc?utm_source=digest&utm_medium=email> > Vassilis Virvilis <[email protected]>: Aug 02 03:41PM +0300 > > Can you expand a little bit on this? Are there any consequences we need to > look for? > > Is there a commit to look at? > > On Mon, Jul 31, 2017 at 8:44 PM, 'Goktug Gokdogan' via GWT Contributors < > > -- > Vassilis Virvilis > Goktug Gokdogan <[email protected]>: Aug 02 10:01AM -0700 > > Unfortunately jsinterop.base doesn't have github repo available yet so you > can't see the commut. > > Change is asArray method is replaced with asList that looks like this: > > @JsOverlay > default List<T> asList() { > // Since it is hidden behind Arrays.asList, it is safe to do uncheckedCast. > T[] asArray = Js.uncheckedCast(this); > return Arrays.asList(asArray); > } > > > > Tony BenBrahim <[email protected]>: Aug 02 02:00PM -0700 > > In my opinion, there is too much effort put in making Array behave like a > normal Java class when it is not. There are already plenty of good options > in GWT/Java for collections, arrays, etc… > A JavaScript Array is not equivalent to T[], for example this is a > perfectly fine JavaScript Array [1,2,3,"abc", true, {x:1, y:2}] and cannot > be modeled in Java. In my opinion, Array should maintain its JavaScript > nature. > > For example if the from method actually returned an Array like it does in > JavaScript: > > public static Array from(JsArrayLike arrayLike); > > instead of > > public static final <T, R> R[] from(JsArrayLike<T> arrayLike); > > then Colin could write > > Array.from(document.querySelectorAll("...")).forEach(element-> ...); > > which looks exactly what you would write in JavaScript, and you would not > have to implement toArray and toList on JsArrayLike, which is not mandated > by the spec (the only requirement for ArrayLike is an indexed getter and > the length attribute) Unfortunately,as it is currently, you cannot chain > to > other Array methods when T[] is the return type. > > I do understand the desire for asList(), because in JavaScript, I might > also write > > for (elem in document.querySelectorAll(...){ > ... > } > > but implementing Iterable would be a more desirable solution if possible. > Back to top <#m_-6068370991899046413_digest_top> > You received this digest because you're subscribed to updates for this > group. You can change your settings on the group membership page > <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/google-web-toolkit-contributors/join> > . > To unsubscribe from this group and stop receiving emails from it send an > email to [email protected]. > -- You received this message because you are subscribed to the Google Groups "GWT Contributors" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/CANjaDnczgsK0o8J5SMcwgbfJq4qg-V%2BXN%2BDH2v3SiYRxEfHyCQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
