@@ -19,8 +19,7 @@ import {
19
19
Output ,
20
20
booleanAttribute ,
21
21
} from '@angular/core' ;
22
- import { HasInitialized , mixinInitialized } from '@angular/material/core' ;
23
- import { Subject } from 'rxjs' ;
22
+ import { Observable , ReplaySubject , Subject } from 'rxjs' ;
24
23
import { SortDirection } from './sort-direction' ;
25
24
import {
26
25
getSortDuplicateSortableIdError ,
@@ -65,10 +64,6 @@ export const MAT_SORT_DEFAULT_OPTIONS = new InjectionToken<MatSortDefaultOptions
65
64
'MAT_SORT_DEFAULT_OPTIONS' ,
66
65
) ;
67
66
68
- // Boilerplate for applying mixins to MatSort.
69
- /** @docs -private */
70
- const _MatSortBase = mixinInitialized ( class { } ) ;
71
-
72
67
/** Container for MatSortables to manage the sort state and provide default sort parameters. */
73
68
@Directive ( {
74
69
selector : '[matSort]' ,
@@ -78,7 +73,9 @@ const _MatSortBase = mixinInitialized(class {});
78
73
} ,
79
74
standalone : true ,
80
75
} )
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
+
82
79
/** Collection of all registered sortables that this directive manages. */
83
80
sortables = new Map < string , MatSortable > ( ) ;
84
81
@@ -126,13 +123,14 @@ export class MatSort extends _MatSortBase implements HasInitialized, OnChanges,
126
123
/** Event emitted when the user changes either the active sort or sort direction. */
127
124
@Output ( 'matSortChange' ) readonly sortChange : EventEmitter < Sort > = new EventEmitter < Sort > ( ) ;
128
125
126
+ /** Emits when the paginator is initialized. */
127
+ initialized : Observable < void > = this . _initializedStream ;
128
+
129
129
constructor (
130
130
@Optional ( )
131
131
@Inject ( MAT_SORT_DEFAULT_OPTIONS )
132
132
private _defaultOptions ?: MatSortDefaultOptions ,
133
- ) {
134
- super ( ) ;
135
- }
133
+ ) { }
136
134
137
135
/**
138
136
* 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,
192
190
}
193
191
194
192
ngOnInit ( ) {
195
- this . _markInitialized ( ) ;
193
+ this . _initializedStream . next ( ) ;
196
194
}
197
195
198
196
ngOnChanges ( ) {
@@ -201,6 +199,7 @@ export class MatSort extends _MatSortBase implements HasInitialized, OnChanges,
201
199
202
200
ngOnDestroy ( ) {
203
201
this . _stateChanges . complete ( ) ;
202
+ this . _initializedStream . complete ( ) ;
204
203
}
205
204
}
206
205
0 commit comments