Why not use org.apache.royale.utils.ObjectMap?


On 11/13/2021 3:24 PM, Greg Dove wrote:
> Sure, if you want, Andrew. This is the way I do it currently, and in some
> cases this has been done within the current framework code (e.g. in Crux
> code there is some use of Map to replace Dictionary in js, iirc)
>
> I do expect to come up with an approach that works much closer to the
> original flash Dictionary using a combination of compiler support, similar
> to thej [RoyaleArrayLike] support and framework code (which would use the
> relatively recent WeakRef support in js).
> I also believe it will be possible to match flash event listener apis with
> support for weak listeners (also using WeakRef - and I would add event
> priority support at the same time).
> But both of these updates would be opt-in and would only be for quite
> modern browsers, but would allow for more unchanged code when porting
> legacy apps. At the moment these are just ideas/vague plans, I need to find
> the time for that.
>
>
>
>
> On Sun, Nov 14, 2021 at 10:07 AM Andrew Wetmore wrote:
>
>> Greg, can I throw that into documentation as a workaround?
>>
>> On Sat., Nov. 13, 2021, 4:45 p.m. Greg Dove, wrote:
>>
>>> Hi Hugo,
>>>
>>> I might change this in the near future. But for now, here is the general
>>> 'rule of thumb' that I use:
>>>
>>> If the instance only has string keys (or int/uint/Number/Boolean keys
>>> should be ok too) then use a plain Object. All code can pretty much then
>>> remain unchanged.
>>>
>>> If it is using object instances (any complex object like functions or
>> class
>>> instances, or generic object instances) as keys, then
>>>
>>> a) use native js Map if the original constructor argument does not have
>>> weakKeys=true, or if it has weakKeys= true and there is any form of
>>> iteration over keys (you cannot iterate over keys in a WeakMap in
>>> javascript)
>>>
>>> b) otherwise use WeakMap.
>>>
>>> Both (a) and (b) require you to change code for get/set ([]
>>> access/assignment in as3) or delete operator, and also code related to
>>> iteration (use map.forEach in js).
>>> see docs for those:
>>>
>>>
>> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
>>>
>> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap
>>>
>>>
>>>
>>> On Sun, Nov 14, 2021 at 9:34 AM Hugo Ferreira <[email protected]>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I see that there is no Dictionary on Royale, probably because there is
>> a
>>>> better method.
>>>> What the approach in Royale for a Dictionary ?
>>>>

Reply via email to