55
66import { NgTemplateOutlet } from '@angular/common' ;
77import {
8+ AfterContentInit ,
89 ChangeDetectionStrategy ,
910 ChangeDetectorRef ,
1011 Component ,
1112 ContentChildren ,
1213 Input ,
13- NgZone ,
1414 OnChanges ,
1515 QueryList ,
1616 TemplateRef ,
1717 ViewChild
1818} from '@angular/core' ;
19- import { defer , merge , MonoTypeOperatorFunction , Observable , of , Subject } from 'rxjs' ;
20- import { exhaustMap , startWith , take , takeUntil } from 'rxjs/operators' ;
19+ import { defer , merge , Observable , of , Subject } from 'rxjs' ;
20+ import { mergeMap , startWith , takeUntil } from 'rxjs/operators' ;
2121
2222import { NzDestroyService } from 'ng-zorro-antd/core/services' ;
2323import { NzSafeAny } from 'ng-zorro-antd/core/types' ;
@@ -66,7 +66,7 @@ export class NzListItemActionComponent {
6666 imports : [ NgTemplateOutlet ] ,
6767 standalone : true
6868} )
69- export class NzListItemActionsComponent implements OnChanges {
69+ export class NzListItemActionsComponent implements OnChanges , AfterContentInit {
7070 @Input ( ) nzActions : Array < TemplateRef < void > > = [ ] ;
7171 @ContentChildren ( NzListItemActionComponent ) nzListItemActions ! : QueryList < NzListItemActionComponent > ;
7272
@@ -76,18 +76,14 @@ export class NzListItemActionsComponent implements OnChanges {
7676 if ( this . nzListItemActions ) {
7777 return of ( null ) ;
7878 }
79- return this . ngZone . onStable . pipe (
80- take ( 1 ) ,
81- this . enterZone ( ) ,
82- exhaustMap ( ( ) => this . nzListItemActions . changes . pipe ( startWith ( this . nzListItemActions ) ) )
79+ return this . initialized . pipe (
80+ mergeMap ( ( ) => this . nzListItemActions . changes . pipe ( startWith ( this . nzListItemActions ) ) )
8381 ) ;
8482 } ) ;
8583
86- constructor (
87- private ngZone : NgZone ,
88- cdr : ChangeDetectorRef ,
89- destroy$ : NzDestroyService
90- ) {
84+ private initialized = new Subject < void > ( ) ;
85+
86+ constructor ( cdr : ChangeDetectorRef , destroy$ : NzDestroyService ) {
9187 merge ( this . contentChildrenChanges$ , this . inputActionChanges$ )
9288 . pipe ( takeUntil ( destroy$ ) )
9389 . subscribe ( ( ) => {
@@ -104,12 +100,8 @@ export class NzListItemActionsComponent implements OnChanges {
104100 this . inputActionChanges$ . next ( null ) ;
105101 }
106102
107- private enterZone < T > ( ) : MonoTypeOperatorFunction < T > {
108- return ( source : Observable < T > ) =>
109- new Observable < T > ( observer =>
110- source . subscribe ( {
111- next : value => this . ngZone . run ( ( ) => observer . next ( value ) )
112- } )
113- ) ;
103+ ngAfterContentInit ( ) : void {
104+ this . initialized . next ( ) ;
105+ this . initialized . complete ( ) ;
114106 }
115107}
0 commit comments