On 3/22/16, 1:07 PM, "[email protected] on behalf of OmPrakash Muppirala"
<[email protected] on behalf of [email protected]> wrote:

>On Tue, Mar 22, 2016 at 12:36 PM, OK <[email protected]> wrote:
>
>> Alex Harui wrote
>> > That said, I also wonder if we should invest instead in better support
>> for
>> > Vector and other templates/generics instead.
>>
>> Agree. I've used ArrayCollection a lot in many projects cause I didn't
>>know
>> it better.
>> In most cases the usage of if was totally useless and bloated.
>>
>
>I have been 'taught' by the Flex SDK to use ArrayCollection because Arrays
>and Vectors do not support data binding :-)

Sure, and if I get this MX/Spark-like component set running, there will
probably be your old familiar ArrayCollection.

But the challenge for folks using FlexJS is that, if you want advanced
optimizations in JS (which I would imagine most of you will want), the
optimizer renames variables which usually requires more strong-typing in
your code.

In your current Flex code, List.selectedItem is of type Object.
ArrayCollection[index] is of type Object.  So whenever you do:

var arr:Array = [ new ValueObject(), new ValueObject() ];
var dp:ArrayCollection = new ArrayCollection(arr);
dp[0].someProperty = "someNewValue";

And/or

myList.dataProvider = dp;
myList.selectedIndex = 1;
trace(myList.selectedItem.someProperty);

And/or

<Label text="{myList.selectedItem.someProperty}" />

These lines with someProperty in them are likely to fail in the optimized
code because the Optimizer thinks this is just an Object, not a
ValueObject with property names that have been directed to not be renamed.

Instead you will have to write:

ValueObject(dp[0]).someProperty = "someNewValue";

Or

trace(ValueObject(myList.selectedItem).someProperty);

Or

<Label text="{ValueObject(myList.selectedItem).someProperty}"

I still hope to teach the compiler to warn about things like that.
Otherwise you won't find out until you run the app and it doesn't work.

The Flex SDK has a VectorCollection, but it is not quite as good as real
templates/generics.  You still lose strong-typing in List.selectedItem and
elsewhere.  So being able to dictate that there is a List<ValueObject> so
the compiler knows that myList.selectedItem is a ValueObject would be a
huge win for developer productivity.  Volunteers are needed.

Thanks,
-Alex

Reply via email to