You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by OK <OK...@edscha.com> on 2016/03/22 13:38:49 UTC

[FlexJS] org.apache.flex.collections.ArrayList vs mx.collections.ArrayList

Hi,
with the goal to get a reusable 'business logic' that works for the standard
SDK and FlexJS I'm trying to get rid of the flex/flash dependencies.

Could mx.collections.ArrayList replaced by
org.apache.flex.collections.ArrayList without any risk using the standard
SDK?

Thanks,
Olaf



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/FlexJS-org-apache-flex-collections-ArrayList-vs-mx-collections-ArrayList-tp12331.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: [FlexJS] org.apache.flex.collections.ArrayList vs mx.collections.ArrayList

Posted by Alex Harui <ah...@adobe.com>.

On 3/22/16, 5:44 AM, "OK" <OK...@edscha.com> wrote:

>Forgot something:
>I can't find a representation of the ArrayCollection. Is there a reason
>why
>it is not implemented in FlexJS?

Well, ArrayCollection uses Proxy.  And we only recently built out support
for Proxy.  So now, I think a volunteer could try to create
ArrayCollection.

That said, I also wonder if we should invest instead in better support for
Vector and other templates/generics instead.

Thanks,
-Alex


Re: [FlexJS] org.apache.flex.collections.ArrayList vs mx.collections.ArrayList

Posted by OK <OK...@edscha.com>.
Forgot something:
I can't find a representation of the ArrayCollection. Is there a reason why
it is not implemented in FlexJS?

Thanks,
Olaf




--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/FlexJS-org-apache-flex-collections-ArrayList-vs-mx-collections-ArrayList-tp12331p12332.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: [FlexJS] org.apache.flex.collections.ArrayList vs mx.collections.ArrayList

Posted by Alex Harui <ah...@adobe.com>.

On 3/22/16, 12:19 PM, "OK" <OK...@edscha.com> wrote:

>Alex Harui wrote
>> Mx.collections.ArrayList does a lot more: it watches each
>> item for changes, it handles serialization, and maybe a few other
>>things.
>> IMO, in FlexJS these capabilities would be added as beads and possible
>
>Sounds like if it is make sense at all to think about a shareable
>'business
>logic' it should be
>implemented by using pure AS3 only.

Yes, any Flash dependencies for serialization should be a separate bead
with equivalent AS that can get cross-compiled and "do the right thing"
without Flash.

-Alex


Re: [FlexJS] org.apache.flex.collections.ArrayList vs mx.collections.ArrayList

Posted by Alex Harui <ah...@adobe.com>.

On 3/22/16, 1:07 PM, "omuppi1@gmail.com on behalf of OmPrakash Muppirala"
<omuppi1@gmail.com on behalf of bigosmallm@gmail.com> wrote:

>On Tue, Mar 22, 2016 at 12:36 PM, OK <OK...@edscha.com> 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


Re: [FlexJS] org.apache.flex.collections.ArrayList vs mx.collections.ArrayList

Posted by OmPrakash Muppirala <bi...@gmail.com>.
On Tue, Mar 22, 2016 at 12:36 PM, OK <OK...@edscha.com> 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 :-)

Thanks,
Om


>
> Thanks,
> Olaf
>
>
>
> --
> View this message in context:
> http://apache-flex-users.2333346.n4.nabble.com/FlexJS-org-apache-flex-collections-ArrayList-vs-mx-collections-ArrayList-tp12331p12345.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>

Re: [FlexJS] org.apache.flex.collections.ArrayList vs mx.collections.ArrayList

Posted by OK <OK...@edscha.com>.
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.

Thanks,
Olaf



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/FlexJS-org-apache-flex-collections-ArrayList-vs-mx-collections-ArrayList-tp12331p12345.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: [FlexJS] org.apache.flex.collections.ArrayList vs mx.collections.ArrayList

Posted by OK <OK...@edscha.com>.
Alex Harui wrote
> Mx.collections.ArrayList does a lot more: it watches each
> item for changes, it handles serialization, and maybe a few other things.
> IMO, in FlexJS these capabilities would be added as beads and possible

Sounds like if it is make sense at all to think about a shareable 'business
logic' it should be
implemented by using pure AS3 only.


Alex Harui wrote
> It would be great for some volunteer to start working on beads that
> provide the missing functionality.

I keep this in mind...

Thanks,
Olaf




--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/FlexJS-org-apache-flex-collections-ArrayList-vs-mx-collections-ArrayList-tp12331p12341.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: [FlexJS] org.apache.flex.collections.ArrayList vs mx.collections.ArrayList

Posted by Alex Harui <ah...@adobe.com>.

On 3/22/16, 5:38 AM, "OK" <OK...@edscha.com> wrote:

>Hi,
>with the goal to get a reusable 'business logic' that works for the
>standard
>SDK and FlexJS I'm trying to get rid of the flex/flash dependencies.
>
>Could mx.collections.ArrayList replaced by
>org.apache.flex.collections.ArrayList without any risk using the standard
>SDK?

Well it depends.  In keeping with the Pay-As-You-Go (PAYG) principle,
org.apache.flex.collection.ArrayList is the most bare-bones Ilist
implementation.  Mx.collections.ArrayList does a lot more: it watches each
item for changes, it handles serialization, and maybe a few other things.
IMO, in FlexJS these capabilities would be added as beads and possible
aggregated into higher-level collections
(ArrayListWithItemChangeDetection).  That's because it is wasteful to scan
a array of the 50 US states for change detection.

It would be great for some volunteer to start working on beads that
provide the missing functionality.

Thanks,
-Alex