本文整理汇总了TypeScript中@angular/core.KeyValueChanges类的典型用法代码示例。如果您正苦于以下问题:TypeScript KeyValueChanges类的具体用法?TypeScript KeyValueChanges怎么用?TypeScript KeyValueChanges使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyValueChanges类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: applyChanges
private applyChanges(changes: KeyValueChanges<string, L.Layer>, addFn: (layer: L.Layer, name: string) => void): LeafletControlLayersChanges {
let results: LeafletControlLayersChanges = new LeafletControlLayersChanges();
if (null != changes) {
changes.forEachChangedItem((c) => {
this.layersControl.removeLayer(c.previousValue);
addFn.call(this.layersControl, c.currentValue, c.key);
results.layersChanged++;
});
changes.forEachRemovedItem((c) => {
this.layersControl.removeLayer(c.currentValue);
results.layersRemoved++;
});
changes.forEachAddedItem((c) => {
addFn.call(this.layersControl, c.currentValue, c.key);
results.layersAdded++;
});
}
return results;
}
示例2:
transform<K, V>(
input: null|{[key: string]: V, [key: number]: V}|Map<K, V>,
compareFn: (a: KeyValue<K, V>, b: KeyValue<K, V>) => number = defaultComparator):
Array<KeyValue<K, V>>|null {
if (!input || (!(input instanceof Map) && typeof input !== 'object')) {
return null;
}
if (!this.differ) {
// make a differ for whatever type we've been passed in
this.differ = this.differs.find(input).create();
}
const differChanges: KeyValueChanges<K, V>|null = this.differ.diff(input as any);
if (differChanges) {
this.keyValues = [];
differChanges.forEachItem((r: KeyValueChangeRecord<K, V>) => {
this.keyValues.push(makeKeyValuePair(r.key, r.currentValue !));
});
this.keyValues.sort(compareFn);
}
return this.keyValues;
}
示例3: _applyChanges
private _applyChanges(changes: KeyValueChanges<string, string|number>): void {
changes.forEachRemovedItem((record) => this._setStyle(record.key, null));
changes.forEachAddedItem((record) => this._setStyle(record.key, record.currentValue));
changes.forEachChangedItem((record) => this._setStyle(record.key, record.currentValue));
}
示例4:
this.zone.runOutsideAngular(() => {
changes.forEachChangedItem((c) => {
this.layersControl.removeLayer(c.previousValue);
addFn.call(this.layersControl, c.currentValue, c.key);
results.layersChanged++;
});
changes.forEachRemovedItem((c) => {
this.layersControl.removeLayer(c.previousValue);
results.layersRemoved++;
});
changes.forEachAddedItem((c) => {
addFn.call(this.layersControl, c.currentValue, c.key);
results.layersAdded++;
});
});