Skip to content
Permalink
Browse files

refactor(core): remove deprecated `DefaultIterableDiffer`, `KeyValueD…

…iffers#factories` & `IterableDiffers#factories`

BREAKING CHANGE: `DefaultIterableDiffer`, `KeyValueDiffers#factories` & `IterableDiffers#factories` are no longer public, they have been removed from the public API as they were deprecated since v4.
  • Loading branch information...
ocombe committed Aug 17, 2017
1 parent 18917ea commit 562bfb83170712499e4f5f7f6f0a8dd70c45861f
@@ -12,4 +12,4 @@
* Change detection enables data binding in Angular.
*/

export {ChangeDetectionStrategy, ChangeDetectorRef, CollectionChangeRecord, DefaultIterableDiffer, IterableChangeRecord, IterableChanges, IterableDiffer, IterableDifferFactory, IterableDiffers, KeyValueChangeRecord, KeyValueChanges, KeyValueDiffer, KeyValueDifferFactory, KeyValueDiffers, NgIterable, PipeTransform, SimpleChange, SimpleChanges, TrackByFunction, WrappedValue} from './change_detection/change_detection';
export {ChangeDetectionStrategy, ChangeDetectorRef, CollectionChangeRecord, IterableChangeRecord, IterableChanges, IterableDiffer, IterableDifferFactory, IterableDiffers, KeyValueChangeRecord, KeyValueChanges, KeyValueDiffer, KeyValueDifferFactory, KeyValueDiffers, NgIterable, PipeTransform, SimpleChange, SimpleChanges, TrackByFunction, WrappedValue} from './change_detection/change_detection';
@@ -23,7 +23,7 @@ export class DefaultIterableDifferFactory implements IterableDifferFactory {
const trackByIdentity = (index: number, item: any) => item;

/**
* @deprecated v4.0.0 - Should not be part of public API.
* @internal
*/
export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChanges<V> {
private _length: number = 0;
@@ -133,11 +133,7 @@ export interface IterableDifferFactory {
* @stable
*/
export class IterableDiffers {
/**
* @deprecated v4.0.0 - Should be private
*/
factories: IterableDifferFactory[];
constructor(factories: IterableDifferFactory[]) { this.factories = factories; }
constructor(private factories: IterableDifferFactory[]) {}

static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers {
if (parent != null) {
@@ -115,12 +115,7 @@ export interface KeyValueDifferFactory {
* @stable
*/
export class KeyValueDiffers {
/**
* @deprecated v4.0.0 - Should be private.
*/
factories: KeyValueDifferFactory[];

constructor(factories: KeyValueDifferFactory[]) { this.factories = factories; }
constructor(private factories: KeyValueDifferFactory[]) {}

static create<S>(factories: KeyValueDifferFactory[], parent?: KeyValueDiffers): KeyValueDiffers {
if (parent) {
@@ -38,32 +38,13 @@ export function main() {
expect(differs.find('some object')).toBe(factory2);
});

it('should copy over differs from the parent repo', () => {
factory1.spy('supports').and.returnValue(true);
factory2.spy('supports').and.returnValue(false);

const parent = IterableDiffers.create(<any>[factory1]);
const child = IterableDiffers.create(<any>[factory2], parent);

expect(child.factories).toEqual([factory2, factory1]);
});

describe('.extend()', () => {
it('should throw if calling extend when creating root injector', () => {
const injector = Injector.create([IterableDiffers.extend([])]);

expect(() => injector.get(IterableDiffers))
.toThrowError(/Cannot extend IterableDiffers without a parent injector/);
});

it('should extend di-inherited differs', () => {
const parent = new IterableDiffers([factory1]);
const injector = Injector.create([{provide: IterableDiffers, useValue: parent}]);
const childInjector = Injector.create([IterableDiffers.extend([factory2])], injector);

expect(injector.get(IterableDiffers).factories).toEqual([factory1]);
expect(childInjector.get(IterableDiffers).factories).toEqual([factory2, factory1]);
});
});
});
}
@@ -329,24 +329,6 @@ export declare class DebugNode {
constructor(nativeNode: any, parent: DebugNode | null, _debugContext: DebugContext);
}

/** @deprecated */
export declare class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChanges<V> {
readonly collection: V[] | Iterable<V> | null;
readonly isDirty: boolean;
readonly length: number;
constructor(trackByFn?: TrackByFunction<V>);
check(collection: NgIterable<V>): boolean;
diff(collection: NgIterable<V>): DefaultIterableDiffer<V> | null;
forEachAddedItem(fn: (record: IterableChangeRecord_<V>) => void): void;
forEachIdentityChange(fn: (record: IterableChangeRecord_<V>) => void): void;
forEachItem(fn: (record: IterableChangeRecord_<V>) => void): void;
forEachMovedItem(fn: (record: IterableChangeRecord_<V>) => void): void;
forEachOperation(fn: (item: IterableChangeRecord<V>, previousIndex: number | null, currentIndex: number | null) => void): void;
forEachPreviousItem(fn: (record: IterableChangeRecord_<V>) => void): void;
forEachRemovedItem(fn: (record: IterableChangeRecord_<V>) => void): void;
onDestroy(): void;
}

/** @experimental */
export declare function destroyPlatform(): void;

@@ -521,7 +503,6 @@ export interface IterableDifferFactory {

/** @stable */
export declare class IterableDiffers {
/** @deprecated */ factories: IterableDifferFactory[];
constructor(factories: IterableDifferFactory[]);
find(iterable: any): IterableDifferFactory;
static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers;
@@ -563,7 +544,6 @@ export interface KeyValueDifferFactory {

/** @stable */
export declare class KeyValueDiffers {
/** @deprecated */ factories: KeyValueDifferFactory[];
constructor(factories: KeyValueDifferFactory[]);
find(kv: any): KeyValueDifferFactory;
static create<S>(factories: KeyValueDifferFactory[], parent?: KeyValueDiffers): KeyValueDiffers;

0 comments on commit 562bfb8

Please sign in to comment.
You can’t perform that action at this time.