@@ -58,7 +58,7 @@ import {
5858} from 'rxjs' ;
5959import { takeUntil } from 'rxjs/operators' ;
6060import { CdkColumnDef } from './cell' ;
61- import { _CoalescedStyleScheduler } from './coalesced-style-scheduler' ;
61+ import { _CoalescedStyleScheduler , _COALESCED_STYLE_SCHEDULER } from './coalesced-style-scheduler' ;
6262import {
6363 BaseRowDef ,
6464 CdkCellOutlet ,
@@ -202,7 +202,7 @@ export interface RenderRow<T> {
202202 providers : [
203203 { provide : CDK_TABLE , useExisting : CdkTable } ,
204204 { provide : _VIEW_REPEATER_STRATEGY , useClass : _DisposeViewRepeaterStrategy } ,
205- _CoalescedStyleScheduler ,
205+ { provide : _COALESCED_STYLE_SCHEDULER , useClass : _CoalescedStyleScheduler } ,
206206 ]
207207} )
208208export class CdkTable < T > implements AfterContentChecked , CollectionViewer , OnDestroy , OnInit {
@@ -476,18 +476,23 @@ export class CdkTable<T> implements AfterContentChecked, CollectionViewer, OnDes
476476 constructor (
477477 protected readonly _differs : IterableDiffers ,
478478 protected readonly _changeDetectorRef : ChangeDetectorRef ,
479- protected readonly _coalescedStyleScheduler : _CoalescedStyleScheduler ,
480479 protected readonly _elementRef : ElementRef , @Attribute ( 'role' ) role : string ,
481480 @Optional ( ) protected readonly _dir : Directionality , @Inject ( DOCUMENT ) _document : any ,
482481 private _platform : Platform ,
483- // Optional for backwards compatibility, but a view repeater strategy will always
484- // be provided.
482+
483+ /**
484+ * @deprecated `_coalescedStyleScheduler`, `_viewRepeater` and `_viewportRuler`
485+ * parameters to become required.
486+ * @breaking -change 11.0.0
487+ */
485488 @Optional ( ) @Inject ( _VIEW_REPEATER_STRATEGY )
486- protected readonly _viewRepeater : _ViewRepeater < T , RenderRow < T > , RowContext < T > > ,
489+ protected readonly _viewRepeater ?: _ViewRepeater < T , RenderRow < T > , RowContext < T > > ,
490+ @Optional ( ) @Inject ( _COALESCED_STYLE_SCHEDULER )
491+ protected readonly _coalescedStyleScheduler ?: _CoalescedStyleScheduler ,
487492 // Optional for backwards compatibility. The viewport ruler is provided in root. Therefore,
488493 // this property will never be null.
489494 // tslint:disable-next-line: lightweight-tokens
490- @Optional ( ) private readonly _viewportRuler : ViewportRuler ) {
495+ @Optional ( ) private readonly _viewportRuler ? : ViewportRuler ) {
491496 if ( ! role ) {
492497 this . _elementRef . nativeElement . setAttribute ( 'role' , 'grid' ) ;
493498 }
@@ -512,9 +517,12 @@ export class CdkTable<T> implements AfterContentChecked, CollectionViewer, OnDes
512517
513518 // Table cell dimensions may change after resizing the window. Signal the sticky styler to
514519 // refresh its cache of cell widths the next time sticky styles are updated.
515- this . _viewportRuler . change ( ) . pipe ( takeUntil ( this . _onDestroy ) ) . subscribe ( ( ) => {
516- this . _forceRecalculateCellWidths = true ;
517- } ) ;
520+ // @breaking -change 11.0.0 Remove null check for _viewportRuler once it's a required parameter.
521+ if ( this . _viewportRuler ) {
522+ this . _viewportRuler . change ( ) . pipe ( takeUntil ( this . _onDestroy ) ) . subscribe ( ( ) => {
523+ this . _forceRecalculateCellWidths = true ;
524+ } ) ;
525+ }
518526 }
519527
520528 ngAfterContentChecked ( ) {
@@ -594,11 +602,14 @@ export class CdkTable<T> implements AfterContentChecked, CollectionViewer, OnDes
594602 return ;
595603 }
596604 const viewContainer = this . _rowOutlet . viewContainer ;
597- this . _viewRepeater . applyChanges (
605+
606+ // @breaking -change 11.0.0 Remove null check for `_viewRepeater`
607+ // once it's a required parameter in the constructor.
608+ this . _viewRepeater ?. applyChanges (
598609 changes ,
599610 viewContainer ,
600611 ( record : IterableChangeRecord < RenderRow < T > > ,
601- adjustedPreviousIndex : number | null ,
612+ _adjustedPreviousIndex : number | null ,
602613 currentIndex : number | null ) => this . _getEmbeddedViewArgs ( record . item , currentIndex ! ) ,
603614 ( record ) => record . item . data ,
604615 ( change : _ViewRepeaterItemChange < RenderRow < T > , RowContext < T > > ) => {
0 commit comments