本文整理汇总了TypeScript中angular2/src/facade/collection.ListWrapper.createImmutable方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ListWrapper.createImmutable方法的具体用法?TypeScript ListWrapper.createImmutable怎么用?TypeScript ListWrapper.createImmutable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/facade/collection.ListWrapper
的用法示例。
在下文中一共展示了ListWrapper.createImmutable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should not diff immutable collections if they are the same', () => {
// Note: Use trackBy to know if diffing happened
var trackByCount = 0;
var trackBy = (index: number, item: any): any => {
trackByCount++;
return item;
};
var differ = new DefaultIterableDiffer(trackBy);
var l1 = ListWrapper.createImmutable([1]);
differ.check(l1);
expect(trackByCount).toBe(1);
expect(differ.toString()).toEqual(iterableChangesAsString({
collection: ['1[null->0]'],
additions: ['1[null->0]']
}));
trackByCount = 0;
differ.check(l1);
expect(trackByCount).toBe(0);
expect(differ.toString())
.toEqual(iterableChangesAsString({collection: ['1'], previous: ['1']}));
trackByCount = 0;
differ.check(l1);
expect(trackByCount).toBe(0);
expect(differ.toString())
.toEqual(iterableChangesAsString({collection: ['1'], previous: ['1']}));
});