fix(core): Remove ChangeDetectorRef Paramter from KeyValueDifferFactory and IterableDifferFactory (#14311)

BREAKING CHANGE:

- `KeyValueDifferFactory` and `IterableDifferFactory` no longer have `ChangeDetectorRef` as 
  a parameter. It was not used and has been there for historical reasons. If you call 
  `DifferFactory.create(...)` remove the `ChangeDetectorRef` argument.
This commit is contained in:
FrozenPandaz
2017-02-09 16:33:44 -05:00
committed by Miško Hevery
parent 56e2f84fe8
commit 45cc444154
9 changed files with 41 additions and 14 deletions

View File

@ -16,8 +16,16 @@ import {IterableChangeRecord, IterableChanges, IterableDiffer, IterableDifferFac
export class DefaultIterableDifferFactory implements IterableDifferFactory {
constructor() {}
supports(obj: Object): boolean { return isListLikeIterable(obj); }
create<V>(cdRef: ChangeDetectorRef, trackByFn?: TrackByFunction<any>): DefaultIterableDiffer<V> {
return new DefaultIterableDiffer<V>(trackByFn);
create<V>(trackByFn?: TrackByFunction<any>): DefaultIterableDiffer<V>;
/**
* @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
*/
create<V>(
cdRefOrTrackBy?: ChangeDetectorRef|TrackByFunction<any>,
trackByFn?: TrackByFunction<any>): DefaultIterableDiffer<V> {
return new DefaultIterableDiffer<V>(trackByFn || <TrackByFunction<any>>cdRefOrTrackBy);
}
}

View File

@ -17,7 +17,12 @@ export class DefaultKeyValueDifferFactory<K, V> implements KeyValueDifferFactory
constructor() {}
supports(obj: any): boolean { return obj instanceof Map || isJsObject(obj); }
create<K, V>(cdRef: ChangeDetectorRef): KeyValueDiffer<K, V> {
create<K, V>(): DefaultKeyValueDiffer<K, V>;
/**
* @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
*/
create<K, V>(cd?: ChangeDetectorRef): KeyValueDiffer<K, V> {
return new DefaultKeyValueDiffer<K, V>();
}
}

View File

@ -137,7 +137,13 @@ export interface TrackByFunction<T> { (index: number, item: T): any; }
*/
export interface IterableDifferFactory {
supports(objects: any): boolean;
create<V>(cdRef: ChangeDetectorRef, trackByFn?: TrackByFunction<V>): IterableDiffer<V>;
create<V>(trackByFn?: TrackByFunction<V>): IterableDiffer<V>;
/**
* @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
*/
create<V>(_cdr?: ChangeDetectorRef|TrackByFunction<V>, trackByFn?: TrackByFunction<V>):
IterableDiffer<V>;
}
/**

View File

@ -10,6 +10,7 @@ import {Optional, Provider, SkipSelf} from '../../di';
import {ChangeDetectorRef} from '../change_detector_ref';
/**
* A differ that tracks changes made to an object over time.
*
@ -108,7 +109,12 @@ export interface KeyValueDifferFactory {
/**
* Create a `KeyValueDiffer`.
*/
create<K, V>(cdRef: ChangeDetectorRef): KeyValueDiffer<K, V>;
create<K, V>(): KeyValueDiffer<K, V>;
/**
* @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
*/
create<K, V>(_cdr?: ChangeDetectorRef): KeyValueDiffer<K, V>;
}
/**