| nav-title | Class data/virtual-array.VirtualArray |
|---|---|
| title | Class data/virtual-array.VirtualArray |
| description | Class data/virtual-array.VirtualArray |
Type parameters: T
Inherits: Observable
Advanced array like class that helps loading items on demand. Use "length" property to specify total number of items,
"loadSize" to specify number of items to be requested in a single request, "itemsLoading" event to handle items request and
"load()" method to copy items into the array. All already loaded items are cached in-memory and when "getItem()" method is called
the array will raise "itemsLoading" event for still not loaded items. Example:
var virtualArray = new VirtualArray<number>(100);
virtualArray.loadSize = 15;
virtualArray.on("itemsLoading", (args: virtualArrayDef.ItemsLoading) => {
var itemsToLoad = new Array<number>();
for (var i = 0; i < args.count; i++) {
itemsToLoad.push(args.index + i);
}
virtualArray.load(args.index, itemsToLoad);
});
- length - Number.
Gets or sets length for the virtual array. - loadSize - Number.
Gets or sets load size for the virtual array.
- getItem( index Number ) T
Returns item at specified index.- index - Number
- return - T
- setItem( index Number, value T )
Sets item at specified index.- index - Number
- value - T
- load( index Number, items Array of T )
Loads items from an array starting at index.- index - Number
- items - Array of T
- on( event String, callback Function... )
- event - String
- callback - Function(data EventData)
- on( event , callback Function... )
Reised when still not loaded items are requested.- event
- callback - Function(args ItemsLoading)
- on( event , callback Function... )
Reised when a change occurs.- event
- callback - Function(args ChangedData of T)