Apache Flex (FlexJS) 0.7.0 API Reference | All Packages | All Classes | Index | Frames No Frames |
LazyCollection

Package | org.apache.flex.collections
Class | public class LazyCollection
Inheritance | LazyCollection EventDispatcher flash.events.EventDispatcher
Implements | IBead, ICollection

Language Version : | ActionScript 3.0

Product Version : | FlexJS 0.0

Runtime Versions : | Flash Player 10.2, AIR 2.6

The LazyCollection class implements a collection whose items require conversion from a source data format to some other data type. For example, converting SOAP or JSON to ActionScript data classes. The Flex SDK used to convert all of the data items when the source data arrived, which, for very large data sets or complex data classes, could lock up the user interface. The lazy collection converts items as they are fetched from the collection, resulting in significant performance savings in many cases. Note that, if you need to compute a summary of data in the collection when the source data arrives, the computation can still lock up the user interface as you will have to visit and convert every data item. Of course, it is possible to compute that summary in a worker or pseudo-thread. The LazyCollection class is designed to be a bead that attaches to a data retrieval strand that dispatches an Event.COMPLETE and has a "data" property that gets passed to the input parser. This LazyCollection does not support adding/removing items from the collection or sending data back to the source. Subclasses have that additional functionality.

Public Properties

| Property | Defined By
--- | --- | ---
|  | id : String An id property for MXML documents. | LazyCollection
|  | inputParser : IInputParser A lazy collection uses an IInputParser to convert the source data items into an array of data items. | LazyCollection
|  | itemConverter : IItemConverter A lazy collection uses an IItemConverter to convert the source data items into the desired data type. | LazyCollection
|  | length : int [read-only] The number of items. | LazyCollection
|  | strand : IStrand [write-only] | LazyCollection

Protected Properties

| Property | Defined By
--- | --- | ---
|  | data : Array The array of desired data types. | LazyCollection
|  | rawData : Array The array of raw data needing conversion. | LazyCollection

Public Methods

| Method | Defined By
--- | --- | ---
|  | LazyCollection() Constructor. | LazyCollection
|  | getItemAt(index:int):Object Fetches an item from the collection, converting it first if necessary. | LazyCollection

Events

| Event | Summary | Defined By
--- | --- | --- | ---
|  | complete | Dispatched when the collection has processed a complete event. | LazyCollection

Property Detail

data | property

`protected var data:Array`

Language Version : | ActionScript 3.0

Product Version : | FlexJS 0.0

Runtime Versions : | Flash Player 10.2, AIR 2.6

The array of desired data types. This array is sparse and unconverted items are therefore undefined in the array.

id | property |

`id:String`

Language Version : | ActionScript 3.0

Product Version : | FlexJS 0.0

Runtime Versions : | Flash Player 10.2, AIR 2.6

An id property for MXML documents.

Implementation
`public function get id():String`
`public function set id(value:String):void`

inputParser | property |

`inputParser:IInputParser`

Language Version : | ActionScript 3.0

Product Version : | FlexJS 0.0

Runtime Versions : | Flash Player 10.2, AIR 2.6

A lazy collection uses an IInputParser to convert the source data items into an array of data items. This is required in order to determine the length of the collection. This conversion happens as the source data arrives so it needs to be fast to avoid locking up the UI.

Implementation
`public function get inputParser():IInputParser`
`public function set inputParser(value:IInputParser):void`

itemConverter | property |

`itemConverter:IItemConverter`

Language Version : | ActionScript 3.0

Product Version : | FlexJS 0.0

Runtime Versions : | Flash Player 10.2, AIR 2.6

A lazy collection uses an IItemConverter to convert the source data items into the desired data type. The converter is only called as items are fetched from the collection.

Implementation
`public function get itemConverter():IItemConverter`
`public function set itemConverter(value:IItemConverter):void`

length | property |

`length:int` [read-only]

Language Version : | ActionScript 3.0

Product Version : | FlexJS 0.0

Runtime Versions : | Flash Player 10.2, AIR 2.6

The number of items.

Implementation
`public function get length():int`

rawData | property |

`protected var rawData:Array`

Language Version : | ActionScript 3.0

Product Version : | FlexJS 0.0

Runtime Versions : | Flash Player 10.2, AIR 2.6

The array of raw data needing conversion.

strand | property |

`strand:IStrand` [write-only]

Language Version : | ActionScript 3.0

Product Version : | FlexJS 0.0

Runtime Versions : | Flash Player 10.2, AIR 2.6

Implementation
`public function set strand(value:IStrand):void`
Constructor Detail

LazyCollection | () | Constructor

`public function LazyCollection()`

Language Version : | ActionScript 3.0

Product Version : | FlexJS 0.0

Runtime Versions : | Flash Player 10.2, AIR 2.6

Constructor.

Method Detail

getItemAt | () | method

`public function getItemAt(index:int):Object`

Language Version : | ActionScript 3.0

Product Version : | FlexJS 0.0

Runtime Versions : | Flash Player 10.2, AIR 2.6

Fetches an item from the collection, converting it first if necessary.

Parameters

| `index:int`

Returns

| `Object`

Event Detail

complete | Event

Event Object Type: `org.apache.flex.events.Event`

Language Version : | ActionScript 3.0

Product Version : | FlexJS 0.0

Runtime Versions : | Flash Player 10.2, AIR 2.6

Dispatched when the collection has processed a complete event.

Mon Sep 5 2016, 07:19 AM -07:00