本文整理匯總了TypeScript中@angular/core.IterableDiffer類的典型用法代碼示例。如果您正苦於以下問題:TypeScript IterableDiffer類的具體用法?TypeScript IterableDiffer怎麽用?TypeScript IterableDiffer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了IterableDiffer類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: ngDoCheck
// ngDoCheck is called every time the component is checked, which is quite a lot as it's checked on every event
ngDoCheck(): void {
const changes = this.differ.diff(this.comments);
if (changes) {
console.log('%cIterableDiffers', 'color:orange', changes);
changes.forEachAddedItem(r =>
console.log('%cAdded', 'color:orange', r.item)
);
changes.forEachRemovedItem(r =>
console.log('%cRemoved', 'color:orange', r.item)
);
}
}
示例2: updateLayers
/**
* Update the state of the layers.
* We use an iterable differ to synchronize the map layers with the state of the bound layers array.
* This is important because it allows us to react to changes to the contents of the array as well
* as changes to the actual array instance.
*/
private updateLayers() {
const map = this.leafletDirective.getMap();
if (null != map && null != this.layersDiffer) {
const changes = this.layersDiffer.diff(this.layersValue);
if (null != changes) {
// Run outside angular to ensure layer events don't trigger change detection
this.zone.runOutsideAngular(() => {
changes.forEachRemovedItem((c) => {
map.removeLayer(c.item);
});
changes.forEachAddedItem((c) => {
map.addLayer(c.item);
});
});
}
}
}
示例3: _clear
/** Clear the children dataNodes. */
protected _clear(): void {
const outlet = this._getNodeOutlet();
if (outlet) {
outlet.viewContainer.clear();
this._dataDiffer.diff([]);
}
}
示例4: updateChildrenNodes
/** Add children dataNodes to the NodeOutlet */
protected updateChildrenNodes(): void {
if (this.nodeOutlet.length && this._children) {
const viewContainer = this.nodeOutlet.first.viewContainer;
this._tree.renderNodeChanges(this._children, this._dataDiffer, viewContainer, this._data);
} else {
// Reset the data differ if there's no children nodes displayed
this._dataDiffer.diff([]);
}
}
示例5: ngOnChanges
ngOnChanges(changes: SimpleChanges): void {
// Create a new columns differ if one does not yet exist. Initialize it based on initial value
// of the columns property.
const columns = changes['columns'].currentValue;
if (!this._columnsDiffer && columns) {
this._columnsDiffer = this._differs.find(columns).create();
this._columnsDiffer.diff(columns);
}
}
示例6: ngOnChanges
ngOnChanges(changes: SimpleChanges): void {
// Create a new columns differ if one does not yet exist. Initialize it based on initial value
// of the columns property or an empty array if none is provided.
if (!this._columnsDiffer) {
const columns = (changes['columns'] && changes['columns'].currentValue) || [];
this._columnsDiffer = this._differs.find(columns).create();
this._columnsDiffer.diff(columns);
}
}
示例7:
ngDoCheck() {
console.log('do check called');
if (this.differ) {
const changes = this.differ.diff(this.items);
console.dir(changes);
}
}
示例8: ngDoCheck
ngDoCheck() {
if (this._differ) {
const changes = this._differ.diff(this._rawItems);
if (changes) {
// TODO: not very efficient right now,
// but premature optimization is the root of all evil.
this._items.all = this._rawItems;
}
}
}
示例9: ngDoCheck
ngDoCheck(): void {
if (!this.differ) {
return;
}
const changes = this.differ.diff(this.easyListForOf);
if (changes) {
this.applyChanges(changes);
}
}
示例10: updateChildrenNodes
/** Add children dataNodes to the NodeOutlet */
protected updateChildrenNodes(children?: T[]): void {
const outlet = this._getNodeOutlet();
if (children) {
this._children = children;
}
if (outlet && this._children) {
const viewContainer = outlet.viewContainer;
this._tree.renderNodeChanges(this._children, this._dataDiffer, viewContainer, this._data);
} else {
// Reset the data differ if there's no children nodes displayed
this._dataDiffer.diff([]);
}
}