Skip to content

Latest commit

 

History

History
52 lines (50 loc) · 2.27 KB

File metadata and controls

52 lines (50 loc) · 2.27 KB
nav-title Class data/virtual-array.VirtualArray
title Class data/virtual-array.VirtualArray
description Class data/virtual-array.VirtualArray

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); });

Instance Properties
  • length - Number.
    Gets or sets length for the virtual array.
  • loadSize - Number.
    Gets or sets load size for the virtual array.
Instance Functions
  • 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.
  • on( event , callback Function... )
    Reised when a change occurs.