Skip to content

Commit

Permalink
refactor(core): remove deprecated core in differs
Browse files Browse the repository at this point in the history
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 1f0de1e
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 52 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/change_detection.ts
Expand Up @@ -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';
Expand Up @@ -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;
Expand Down
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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]);
});
});
});
}
20 changes: 0 additions & 20 deletions tools/public_api_guard/core/core.d.ts
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1f0de1e

Please sign in to comment.