本文整理匯總了TypeScript中tns-core-modules/data/virtual-array.VirtualArray.on方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript VirtualArray.on方法的具體用法?TypeScript VirtualArray.on怎麽用?TypeScript VirtualArray.on使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tns-core-modules/data/virtual-array.VirtualArray
的用法示例。
在下文中一共展示了VirtualArray.on方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
export var test_VirtualArray_loadShouldRaiseChangeEventWithCorrectArgs = function () {
// >> virtual-array-change
var array = new virtualArrayModule.VirtualArray<number>(100);
array.loadSize = 15;
// >> (hide)
var result: virtualArrayModule.ChangedData<number>;
var index = 0;
// << (hide)
array.on(virtualArrayModule.VirtualArray.changeEvent, (args: virtualArrayModule.ChangedData<number>) => {
// Argument (args) is ChangedData<T>.
// args.eventName is "change".
// args.action is "update".
// args.removed.length and result.addedCount are equal to number of loaded items with load() method.
// >> (hide)
result = args;
// << (hide)
});
var itemsToLoad = [0, 1, 2];
array.load(index, itemsToLoad);
// << virtual-array-change
TKUnit.assert(result && result.eventName === "change" && result.action === virtualArrayModule.ChangeType.Update &&
result.removed.length === itemsToLoad.length && result.index === index && result.addedCount === itemsToLoad.length,
"VirtualArray<T> load() should raise 'change' event with correct args!");
};
示例2: function
export var test_VirtualArray_shouldNotRaiseItemsLoadingIfIndexIsLoadedAndGetItemIsCalled = function () {
var array = new virtualArrayModule.VirtualArray<number>(100);
array.setItem(0, 0);
array.loadSize = 15;
var result: virtualArrayModule.ItemsLoading;
array.on(virtualArrayModule.VirtualArray.itemsLoadingEvent, (args: virtualArrayModule.ItemsLoading) => {
result = args;
});
array.getItem(0);
TKUnit.assert(types.isUndefined(result), "VirtualArray<T> getItem() should not raise 'itemsLoading' event if item is loaded!");
};