Skip to content

Commit db879d5

Browse files
crisbetommalerba
authored andcommitted
refactor(collections): remove deprecated APIs for 9.0.0 (#17302)
Removes the breaking changes for 9.0 from the cdk/collections entry point. Also renames the file with the SelectionModel so it's consistent with the class that it contains. BREAKING CHANGES: * `SelectionModel.onChange` has been removed. Use `SelectionModel.changed` instead.
1 parent 05600a2 commit db879d5

File tree

11 files changed

+26
-24
lines changed

11 files changed

+26
-24
lines changed

src/cdk/collections/public-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
export * from './array-data-source';
1010
export * from './collection-viewer';
1111
export * from './data-source';
12-
export * from './selection';
12+
export * from './selection-model';
1313
export {
1414
UniqueSelectionDispatcher,
1515
UniqueSelectionDispatcherListener,

src/cdk/collections/selection.ts renamed to src/cdk/collections/selection-model.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ export class SelectionModel<T> {
3636
/** Event emitted when the value has changed. */
3737
changed: Subject<SelectionChange<T>> = new Subject();
3838

39-
/**
40-
* Event emitted when the value has changed.
41-
* @deprecated Use `changed` instead.
42-
* @breaking-change 8.0.0 To be changed to `changed`
43-
*/
44-
onChange: Subject<SelectionChange<T>> = this.changed;
45-
4639
constructor(
4740
private _multiple = false,
4841
initiallySelectedValues?: T[],

src/cdk/collections/selection.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {getMultipleValuesInSingleSelectionError, SelectionModel} from './selection';
1+
import {getMultipleValuesInSingleSelectionError, SelectionModel} from './selection-model';
22

33

44
describe('SelectionModel', () => {

src/cdk/collections/tree-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {SelectionModel} from './selection';
9+
import {SelectionModel} from './selection-model';
1010

1111

1212
/**

src/cdk/schematics/ng-update/data/property-names.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,24 @@ export interface PropertyNameUpgradeData {
2222
}
2323

2424
export const propertyNames: VersionChanges<PropertyNameUpgradeData> = {
25-
[TargetVersion.V9]: [{
26-
pr: 'https://github.com/angular/components/pull/17084',
27-
changes: [{
28-
replace: 'boundaryElementSelector',
29-
replaceWith: 'boundaryElement',
30-
whitelist: {classes: ['CdkDrag']}
31-
}]
32-
}],
25+
[TargetVersion.V9]: [
26+
{
27+
pr: 'https://github.com/angular/components/pull/17084',
28+
changes: [{
29+
replace: 'boundaryElementSelector',
30+
replaceWith: 'boundaryElement',
31+
whitelist: {classes: ['CdkDrag']}
32+
}]
33+
},
34+
{
35+
pr: 'https://github.com/angular/components/pull/17302',
36+
changes: [{
37+
replace: 'onChange',
38+
replaceWith: 'changed',
39+
whitelist: {classes: ['SelectionModel']}
40+
}]
41+
}
42+
],
3343
[TargetVersion.V8]: [],
3444
[TargetVersion.V7]: [
3545
{

src/dev-app/tree/dynamic-tree-demo/dynamic-database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class DynamicDataSource {
6868
private _database: DynamicDatabase) {}
6969

7070
connect(collectionViewer: CollectionViewer): Observable<DynamicFlatNode[]> {
71-
this._treeControl.expansionModel.onChange.subscribe(change => {
71+
this._treeControl.expansionModel.changed.subscribe(change => {
7272
if (change.added || change.removed) {
7373
this.handleTreeControl(change);
7474
}

src/material-examples/material/tree/tree-dynamic/tree-dynamic-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class DynamicDataSource {
5959
private _database: DynamicDatabase) {}
6060

6161
connect(collectionViewer: CollectionViewer): Observable<DynamicFlatNode[]> {
62-
this._treeControl.expansionModel.onChange.subscribe(change => {
62+
this._treeControl.expansionModel.changed.subscribe(change => {
6363
if ((change as SelectionChange<DynamicFlatNode>).added ||
6464
(change as SelectionChange<DynamicFlatNode>).removed) {
6565
this.handleTreeControl(change as SelectionChange<DynamicFlatNode>);

src/material/list/selection-list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements CanD
400400
}
401401

402402
// Sync external changes to the model back to the options.
403-
this.selectedOptions.onChange.pipe(takeUntil(this._destroyed)).subscribe(event => {
403+
this.selectedOptions.changed.pipe(takeUntil(this._destroyed)).subscribe(event => {
404404
if (event.added) {
405405
for (let item of event.added) {
406406
item.selected = true;

src/material/select/select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
539539
ngAfterContentInit() {
540540
this._initKeyManager();
541541

542-
this._selectionModel.onChange.pipe(takeUntil(this._destroy)).subscribe(event => {
542+
this._selectionModel.changed.pipe(takeUntil(this._destroy)).subscribe(event => {
543543
event.added.forEach(option => option.select());
544544
event.removed.forEach(option => option.deselect());
545545
});

src/material/tree/data-source/flat-data-source.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class MatTreeFlatDataSource<T, F> extends DataSource<F> {
149149
connect(collectionViewer: CollectionViewer): Observable<F[]> {
150150
const changes = [
151151
collectionViewer.viewChange,
152-
this._treeControl.expansionModel.onChange,
152+
this._treeControl.expansionModel.changed,
153153
this._flattenedData
154154
];
155155
return merge(...changes).pipe(map(() => {

tools/public_api_guard/cdk/collections.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export interface SelectionChange<T> {
3030

3131
export declare class SelectionModel<T> {
3232
changed: Subject<SelectionChange<T>>;
33-
onChange: Subject<SelectionChange<T>>;
3433
readonly selected: T[];
3534
constructor(_multiple?: boolean, initiallySelectedValues?: T[], _emitChanges?: boolean);
3635
clear(): void;

0 commit comments

Comments
 (0)