本文整理匯總了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!");
};