Re: elemental2: Native maps with primitive types?

2019-08-16 Thread Vassilis Virvilis
thanks that worked too.

It is Js.asAny(@DonotAutobox Object o) which performs an unchecked cast below.

Thanks for tips.

On Thu, Aug 15, 2019 at 9:53 AM Peter Donald  wrote:
>
>
>
> On Thu, Aug 15, 2019 at 4:28 PM Vassilis Virvilis  wrote:
>>
>> I have seen the @DoNotAutoBox and I tried with Integer, Number, JsNumber.
>>
>> Note: I can put int in the JsPropertyMap but I cannot read it back. So
>> I cast it to (double) and the then to (int). I believe that is because
>> JavaScript does not have int type.
>
>
> That is certainly an option but in some circumstances can lead to type issues 
> when casting. I tend to prefer using Any to do these sorts of conversions. It 
> is a little more verbose but it avoids any unexpected casting problems. I 
> don't have the code in front of me but I believe there is a method like 
> getAsAny("myprop") that works in this scenario
>
>>
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEzHuG5ZC7igRyvzrkLt26qBWkxNUeuWL%2BZNbKCo%2BcShgA%40mail.gmail.com.
>
>
>
> --
> Cheers,
>
> Peter Donald
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/google-web-toolkit/CACiKNc6CpmL2naFFydC%2BYS%3Dmtj3yQFsQ2KojGQCRAXXSRCYhLg%40mail.gmail.com.



-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEzCi0CnTpDkQZJU%3D1HN9sMnCR2S2NzsoJ2Skf6gzPB9FA%40mail.gmail.com.


Re: elemental2: Native maps with primitive types?

2019-08-15 Thread Peter Donald
On Thu, Aug 15, 2019 at 4:28 PM Vassilis Virvilis  wrote:

> I have seen the @DoNotAutoBox and I tried with Integer, Number, JsNumber.
>
> Note: I can put int in the JsPropertyMap but I cannot read it back. So
> I cast it to (double) and the then to (int). I believe that is because
> JavaScript does not have int type.
>

That is certainly an option but in some circumstances can lead to type
issues when casting. I tend to prefer using Any to do these sorts of
conversions. It is a little more verbose but it avoids any unexpected
casting problems. I don't have the code in front of me but I believe there
is a method like getAsAny("myprop") that works in this scenario


>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEzHuG5ZC7igRyvzrkLt26qBWkxNUeuWL%2BZNbKCo%2BcShgA%40mail.gmail.com
> .
>


-- 
Cheers,

Peter Donald

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/CACiKNc6CpmL2naFFydC%2BYS%3Dmtj3yQFsQ2KojGQCRAXXSRCYhLg%40mail.gmail.com.


Re: elemental2: Native maps with primitive types?

2019-08-15 Thread Vassilis Virvilis
yep

that worked. thanks a bunch.

I have seen the @DoNotAutoBox and I tried with Integer, Number, JsNumber.

Note: I can put int in the JsPropertyMap but I cannot read it back. So
I cast it to (double) and the then to (int). I believe that is because
JavaScript does not have int type.

thanks again.


On Wed, Aug 14, 2019 at 5:38 PM Jens  wrote:
>
> JsPropertyMap.set(key, value) is marked with @DoNotAutoBox, so I guess you 
> should be able to use JsPropertyMap and set int, float, double into 
> it without them being auto boxed.
>
> -- 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/google-web-toolkit/dd759896-4174-411d-b870-593054e1c660%40googlegroups.com.



-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEzHuG5ZC7igRyvzrkLt26qBWkxNUeuWL%2BZNbKCo%2BcShgA%40mail.gmail.com.


Re: elemental2: Native maps with primitive types?

2019-08-14 Thread Jens
JsPropertyMap.set(key, value) is marked with @DoNotAutoBox, so I guess you 
should be able to use JsPropertyMap and set int, float, double into 
it without them being auto boxed.

-- 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/dd759896-4174-411d-b870-593054e1c660%40googlegroups.com.