Skip to content

Commit 04e5058

Browse files
committed
refactor(cdk/observers): switch to input transforms
Switches inputs in cdk/observers to use transforms instead of getters/setters.
1 parent 9248311 commit 04e5058

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/cdk/observers/observe-content.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {
10-
coerceBooleanProperty,
11-
coerceNumberProperty,
12-
coerceElement,
13-
BooleanInput,
14-
NumberInput,
15-
} from '@angular/cdk/coercion';
9+
import {coerceNumberProperty, coerceElement, NumberInput} from '@angular/cdk/coercion';
1610
import {
1711
AfterContentInit,
1812
Directive,
@@ -24,6 +18,7 @@ import {
2418
NgZone,
2519
OnDestroy,
2620
Output,
21+
booleanAttribute,
2722
} from '@angular/core';
2823
import {Observable, Subject, Subscription, Observer} from 'rxjs';
2924
import {debounceTime} from 'rxjs/operators';
@@ -148,12 +143,12 @@ export class CdkObserveContent implements AfterContentInit, OnDestroy {
148143
* Whether observing content is disabled. This option can be used
149144
* to disconnect the underlying MutationObserver until it is needed.
150145
*/
151-
@Input('cdkObserveContentDisabled')
146+
@Input({alias: 'cdkObserveContentDisabled', transform: booleanAttribute})
152147
get disabled(): boolean {
153148
return this._disabled;
154149
}
155-
set disabled(value: BooleanInput) {
156-
this._disabled = coerceBooleanProperty(value);
150+
set disabled(value: boolean) {
151+
this._disabled = value;
157152
this._disabled ? this._unsubscribe() : this._subscribe();
158153
}
159154
private _disabled = false;

tools/public_api_guard/cdk/observers.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
```ts
66

77
import { AfterContentInit } from '@angular/core';
8-
import { BooleanInput } from '@angular/cdk/coercion';
98
import { ElementRef } from '@angular/core';
109
import { EventEmitter } from '@angular/core';
1110
import * as i0 from '@angular/core';
@@ -20,9 +19,11 @@ export class CdkObserveContent implements AfterContentInit, OnDestroy {
2019
get debounce(): number;
2120
set debounce(value: NumberInput);
2221
get disabled(): boolean;
23-
set disabled(value: BooleanInput);
22+
set disabled(value: boolean);
2423
readonly event: EventEmitter<MutationRecord[]>;
2524
// (undocumented)
25+
static ngAcceptInputType_disabled: unknown;
26+
// (undocumented)
2627
ngAfterContentInit(): void;
2728
// (undocumented)
2829
ngOnDestroy(): void;

0 commit comments

Comments
 (0)