本文整理汇总了TypeScript中tns-core-modules/data/observable-array.ObservableArray.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ObservableArray.on方法的具体用法?TypeScript ObservableArray.on怎么用?TypeScript ObservableArray.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tns-core-modules/data/observable-array.ObservableArray
的用法示例。
在下文中一共展示了ObservableArray.on方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
export const test_ObservableArray_spliceShouldRemoveAndInertSpecifiedNumberOfElementsStartingFromSpecifiedIndexAndRaiseChangeEventWithCorrectArgs = function () {
let result: ChangedData<number>;
// >> observable-array-splice-args-change
const array = new ObservableArray(["one", "two", "three"]);
array.on(ObservableArray.changeEvent, (args: ChangedData<number>) => {
// Argument (args) is ChangedData<T>.
// args.eventName is "change".
// args.action is "splice".
// args.index is the start index.
// args.removed.length is equal to the number of deleted items.
// args.addedCount is equal to the delta between number of inserted items and number of deleted items but not less than 0.
// >> (hide)
result = args;
// << (hide)
});
array.splice(1, 2, "six", "seven", "eight");
// << observable-array-splice-args-change
TKUnit.assert(result.eventName === ObservableArray.changeEvent && result.action === ChangeType.Splice &&
result.removed.length === 2 && result.index === 1 && result.addedCount === 1, "ObservableArray splice() should raise 'change' event with correct args!");
};