Skip to content

Commit 8d5a7b5

Browse files
committed
address feedback
1 parent ed36bf2 commit 8d5a7b5

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/material-experimental/mdc-list/list-base.ts

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

9-
import {AfterContentInit, ElementRef, NgZone, OnDestroy, QueryList} from '@angular/core';
9+
import {ElementRef, NgZone, OnDestroy, QueryList} from '@angular/core';
1010
import {setLines} from '@angular/material/core';
1111
import {Subscription} from 'rxjs';
12-
import {startWith} from 'rxjs/operators';
1312

1413
export class MatListBase {}
1514

16-
export class MatListItemBase implements AfterContentInit, OnDestroy {
15+
export class MatListItemBase implements OnDestroy {
1716
lines: QueryList<ElementRef<Element>>;
1817

1918
private _subscriptions = new Subscription();
2019

21-
constructor(protected _element: ElementRef, protected _ngZone: NgZone) {}
20+
constructor(protected _element: ElementRef, protected _ngZone: NgZone) {
21+
this._monitorLines();
22+
}
2223

23-
ngAfterContentInit() {
24+
/**
25+
* Subscribes to changes in `MatLine` content children and annotates them appropriately when they
26+
* change.
27+
*/
28+
private _monitorLines() {
2429
this._ngZone.runOutsideAngular(() => {
25-
this._subscriptions.add(this.lines.changes.pipe(startWith(this.lines))
26-
.subscribe((lines: QueryList<ElementRef<Element>>) => {
30+
this._subscriptions.add(
31+
this.lines.changes.subscribe((lines: QueryList<ElementRef<Element>>) => {
2732
lines.forEach((line: ElementRef<Element>, index: number) => {
2833
line.nativeElement.classList.toggle('mdc-list-item__primary-text', index === 0);
2934
line.nativeElement.classList.toggle('mdc-list-item__secondary-text', index !== 0);

0 commit comments

Comments
 (0)