@@ -19,8 +19,7 @@ import {
1919 Output ,
2020 booleanAttribute ,
2121} from '@angular/core' ;
22- import { HasInitialized , mixinInitialized } from '@angular/material/core' ;
23- import { Subject } from 'rxjs' ;
22+ import { Observable , ReplaySubject , Subject } from 'rxjs' ;
2423import { SortDirection } from './sort-direction' ;
2524import {
2625 getSortDuplicateSortableIdError ,
@@ -65,10 +64,6 @@ export const MAT_SORT_DEFAULT_OPTIONS = new InjectionToken<MatSortDefaultOptions
6564 'MAT_SORT_DEFAULT_OPTIONS' ,
6665) ;
6766
68- // Boilerplate for applying mixins to MatSort.
69- /** @docs -private */
70- const _MatSortBase = mixinInitialized ( class { } ) ;
71-
7267/** Container for MatSortables to manage the sort state and provide default sort parameters. */
7368@Directive ( {
7469 selector : '[matSort]' ,
@@ -78,7 +73,9 @@ const _MatSortBase = mixinInitialized(class {});
7873 } ,
7974 standalone : true ,
8075} )
81- export class MatSort extends _MatSortBase implements HasInitialized , OnChanges , OnDestroy , OnInit {
76+ export class MatSort implements OnChanges , OnDestroy , OnInit {
77+ private _initializedStream = new ReplaySubject < void > ( 1 ) ;
78+
8279 /** Collection of all registered sortables that this directive manages. */
8380 sortables = new Map < string , MatSortable > ( ) ;
8481
@@ -126,13 +123,14 @@ export class MatSort extends _MatSortBase implements HasInitialized, OnChanges,
126123 /** Event emitted when the user changes either the active sort or sort direction. */
127124 @Output ( 'matSortChange' ) readonly sortChange : EventEmitter < Sort > = new EventEmitter < Sort > ( ) ;
128125
126+ /** Emits when the paginator is initialized. */
127+ initialized : Observable < void > = this . _initializedStream ;
128+
129129 constructor (
130130 @Optional ( )
131131 @Inject ( MAT_SORT_DEFAULT_OPTIONS )
132132 private _defaultOptions ?: MatSortDefaultOptions ,
133- ) {
134- super ( ) ;
135- }
133+ ) { }
136134
137135 /**
138136 * Register function to be used by the contained MatSortables. Adds the MatSortable to the
@@ -192,7 +190,7 @@ export class MatSort extends _MatSortBase implements HasInitialized, OnChanges,
192190 }
193191
194192 ngOnInit ( ) {
195- this . _markInitialized ( ) ;
193+ this . _initializedStream . next ( ) ;
196194 }
197195
198196 ngOnChanges ( ) {
@@ -201,6 +199,7 @@ export class MatSort extends _MatSortBase implements HasInitialized, OnChanges,
201199
202200 ngOnDestroy ( ) {
203201 this . _stateChanges . complete ( ) ;
202+ this . _initializedStream . complete ( ) ;
204203 }
205204}
206205
0 commit comments