flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: FlexJS HTTPService for XML parsing
Date Tue, 01 Mar 2016 16:23:22 GMT
Hi,

FlexJS doesn't have XML support yet.  One committer is working on it.

Even when we get it to work, it isn't clear how fast it will be.  In
general XML apis aren't even fast in the Flash/AIR runtime.  So of those
reasons, the current FlexJS APIs support inputParsers and itemConverters
because I've used these patterns in the past to performance tune some big
apps and wanted to make sure such a feature would work when cross-compiled.

A LazyCollection converts raw data into ValueObjects on-demand.  If you
think about how Flex works today, suppose you get 1000 rows in XML from
your server.  The Player is currently going to lock up the UI while it
converts the huge String to XML and then, if you are using an XMLDecoder,
run a loop from 1 to 1000 to convert each item to a ValueObject.  If you
don't use an XMLDecoder, then you are using XML and XMLList directly in
your app and paying the price for every property fetch on the XML data.
XML property fetches can be an order of magnitude (or more) slower than
ValueObject fetches so if you are having performance issues as folks
scroll a DataGrid with a lot of columns and rows, you might get better
performance using ValueObjects, but then you have to freeze the UI while
you convert the ValueObjects when the server payload is received.  Yes, we
can now use Workers to try to move this to the background, but I don't
want to require every FlexJS runtime to support Workers.

So, a LazyCollection actually only converts the raw data to a ValueObject
on the first time it is fetched via getItemAt().  This is slightly less
efficient if you absolutely need to visit every row in the data to compute
a sum or group, but otherwise, if 1000 rows come in, and only 30 rows are
being shown, only 30 rows get converted and the time the UI is locked up
is much smaller.

So, if you think you will need to take advantage of lazy conversion of
data to ValueObjects, I would recommend that you not wait for the XML
support and try to write your own converters and parsers.  I haven't tried
to write them for XML, we only have them for JSON, but maybe you or some
other volunteer can do it.

HTH,
-Alex

On 3/1/16, 1:16 AM, "santanu4ver" <santanu4ver@gmail.com> wrote:

>
>Therefore I dig more with FlexJS 0.5.0 provided examples and in
>'FlexWebsiteStatsViewer' example I noticed these following codes where
>HTTPService calls in MXML tag:
>
><js:HTTPService id="service" method="POST">
>	<js:LazyCollection id="collection">
>		<js:inputParser>
>			<controllers:GAJSONInputParser />
>		</js:inputParser>
>		<js:itemConverter>
>			<controllers:GAStatsDataJSONItemConverter />
>		</js:itemConverter>
>	</js:LazyCollection>
></js:HTTPService>
>
>After more investigation into the code/data-incoming, I felt:
>
>1. GAJSONInputParser is receiving incoming data as String and therefore
>giving a shape to the String by subStr etc.
>2. GAStatsDataJSONItemConverter then returned String value by
>GAJSONInputParser and converted things into object by parsing the String
>by
>subStr etc.
>
>I tried our URL call with this above way now. I noticed that I received
>XML
>as String inside GAJSONInputParser class. So, here are the question I'm
>now
>standing in front of:
>
>1. Should we need to always use HTTPService in MXML tag - the way I
>mentioned above?
>2. If #1 is No, then what is failing in my earlier ActionScript codes
>(that
>I've pasted in beginning of this post)
>3. Why I am having 'variable XML is undefined' - FlexJS provides any API
>to
>read XML object?
>4. Do I need to parse an XML by String.substr way only? (as above example
>parsing JSON String)
>5. Why FlexJS Alert is not working when ran as HTML?
>
>
>
>--
>View this message in context:
>http://apache-flex-users.2333346.n4.nabble.com/FlexJS-HTTPService-for-XML-
>parsing-tp12094.html
>Sent from the Apache Flex Users mailing list archive at Nabble.com.

Mime
View raw message