The compatibility works well when you write all of the code in Java and
leave the JavaScript intricacies to GWT.
That completely breaks down when you are working at the JavaScript level
with JsInterop, because it allows you to do things you could not do in Java
without JSNI or jsinterop.
Take for example this sparse array:

arr=[], arr[0]=10, arr[10]=20; console.log(arr.length); arr.forEach(x
=> console.log(x));111020

Even though the length of the sparse array is 11, the iterator only returns
the 2 defined elements. The only way to correctly model that behavior is
with asIterable() rather than asList(). I have implemented just that, so it
is very doable.
​

On Thu, Aug 3, 2017 at 6:00 AM, Arnaud TOURNIER <ltea...@gmail.com> wrote:

> 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, <google-web-toolkit-
> contribut...@googlegroups.com> a écrit :
>
>> google-web-toolkit-contributors@googlegroups.com
>> <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_1814740188090366034_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 <vasv...@gmail.com>: 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 <gok...@google.com>: 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 <tony.benbra...@gmail.com>: 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_1814740188090366034_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 google-web-toolkit-contributors+unsubscr...@googlegroups.com.
>>
> --
> 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 google-web-toolkit-contributors+unsubscr...@googlegroups.com.
> 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
> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/CANjaDnczgsK0o8J5SMcwgbfJq4qg-V%2BXN%2BDH2v3SiYRxEfHyCQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 google-web-toolkit-contributors+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CADS2qKugPdzXjr6hUDu1rxony_uS_%3Dhr0%2BPpVwrmR2coFs1viw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to