Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(module:autocomplete): remove NgZone dependency (#8462)
This commit eliminates the `NgZone` dependency from the autocomplete component. Since zone.js is becoming optional, `onStable` won't emit any value when `provideZonelessChangeDetection` is used in the application config. Instead, we now use the alternative approach provided by `afterNextRender`. Most of the code that was using `onStable` should be replaced with `afterNextRender`.
- Loading branch information
Showing
6 changed files
with
69 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE | ||
*/ | ||
|
||
import { InjectionToken, Injector, afterNextRender, inject } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
|
||
/** | ||
* An injection token representing `afterNextRender` as an observable rather | ||
* than a callback-based API has been added. This might be necessary in code | ||
* where streams of data are already being used and we need to wait until | ||
* the change detection ends before performing any tasks. | ||
*/ | ||
export const NZ_AFTER_NEXT_RENDER$ = new InjectionToken<Observable<void>>('nz-after-next-render', { | ||
providedIn: 'root', | ||
factory: () => { | ||
const injector = inject(Injector); | ||
|
||
return new Observable<void>(subscriber => { | ||
const ref = afterNextRender( | ||
() => { | ||
subscriber.next(); | ||
subscriber.complete(); | ||
}, | ||
{ injector } | ||
); | ||
|
||
return () => ref.destroy(); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE | ||
*/ | ||
|
||
export * from './public-api'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"lib": { | ||
"entryFile": "public-api.ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE | ||
*/ | ||
|
||
export * from './after-next-render'; |