@@ -22,12 +22,12 @@ import {
22
22
booleanAttribute ,
23
23
numberAttribute ,
24
24
} from '@angular/core' ;
25
- import { MatFormField , MatFormFieldAppearance } from '@angular/material/form-field' ;
26
- import { HasInitialized , MatOption , mixinInitialized , ThemePalette } from '@angular/material/core' ;
25
+ import { MatOption , ThemePalette } from '@angular/material/core' ;
27
26
import { MatSelect } from '@angular/material/select' ;
28
27
import { MatIconButton } from '@angular/material/button' ;
29
28
import { MatTooltip } from '@angular/material/tooltip' ;
30
- import { Subscription } from 'rxjs' ;
29
+ import { MatFormField , MatFormFieldAppearance } from '@angular/material/form-field' ;
30
+ import { Observable , ReplaySubject , Subscription } from 'rxjs' ;
31
31
import { MatPaginatorIntl } from './paginator-intl' ;
32
32
33
33
/** The default page size if there is no page size and there are no provided page size options. */
@@ -90,10 +90,6 @@ export const MAT_PAGINATOR_DEFAULT_OPTIONS = new InjectionToken<MatPaginatorDefa
90
90
'MAT_PAGINATOR_DEFAULT_OPTIONS' ,
91
91
) ;
92
92
93
- // Boilerplate for applying mixins to _MatPaginatorBase.
94
- /** @docs -private */
95
- const _MatPaginatorMixinBase = mixinInitialized ( class { } ) ;
96
-
97
93
let nextUniqueId = 0 ;
98
94
99
95
/**
@@ -115,18 +111,16 @@ let nextUniqueId = 0;
115
111
standalone : true ,
116
112
imports : [ MatFormField , MatSelect , MatOption , MatIconButton , MatTooltip ] ,
117
113
} )
118
- export class MatPaginator
119
- extends _MatPaginatorMixinBase
120
- implements OnInit , OnDestroy , HasInitialized
121
- {
114
+ export class MatPaginator implements OnInit , OnDestroy {
122
115
/** If set, styles the "page size" form field with the designated style. */
123
116
_formFieldAppearance ?: MatFormFieldAppearance ;
124
117
125
118
/** ID for the DOM node containing the paginator's items per page label. */
126
119
readonly _pageSizeLabelId = `mat-paginator-page-size-label-${ nextUniqueId ++ } ` ;
127
120
128
- private _initialized : boolean ;
129
121
private _intlChanges : Subscription ;
122
+ private _isInitialized = false ;
123
+ private _initializedStream = new ReplaySubject < void > ( 1 ) ;
130
124
131
125
/** Theme color to be used for the underlying form controls. */
132
126
@Input ( ) color : ThemePalette ;
@@ -196,12 +190,14 @@ export class MatPaginator
196
190
/** Displayed set of page size options. Will be sorted and include current page size. */
197
191
_displayedPageSizeOptions : number [ ] ;
198
192
193
+ /** Emits when the paginator is initialized. */
194
+ initialized : Observable < void > = this . _initializedStream ;
195
+
199
196
constructor (
200
197
public _intl : MatPaginatorIntl ,
201
198
private _changeDetectorRef : ChangeDetectorRef ,
202
199
@Optional ( ) @Inject ( MAT_PAGINATOR_DEFAULT_OPTIONS ) defaults ?: MatPaginatorDefaultOptions ,
203
200
) {
204
- super ( ) ;
205
201
this . _intlChanges = _intl . changes . subscribe ( ( ) => this . _changeDetectorRef . markForCheck ( ) ) ;
206
202
207
203
if ( defaults ) {
@@ -228,12 +224,13 @@ export class MatPaginator
228
224
}
229
225
230
226
ngOnInit ( ) {
231
- this . _initialized = true ;
227
+ this . _isInitialized = true ;
232
228
this . _updateDisplayedPageSizeOptions ( ) ;
233
- this . _markInitialized ( ) ;
229
+ this . _initializedStream . next ( ) ;
234
230
}
235
231
236
232
ngOnDestroy ( ) {
233
+ this . _initializedStream . complete ( ) ;
237
234
this . _intlChanges . unsubscribe ( ) ;
238
235
}
239
236
@@ -337,7 +334,7 @@ export class MatPaginator
337
334
* the page size is an option and that the list is sorted.
338
335
*/
339
336
private _updateDisplayedPageSizeOptions ( ) {
340
- if ( ! this . _initialized ) {
337
+ if ( ! this . _isInitialized ) {
341
338
return ;
342
339
}
343
340
0 commit comments