perf(frontend): optimize initial bundle size with lazy-loaded dialogs and localized chart providers (#1110)
This commit is contained in:
@@ -28,7 +28,7 @@ describe('IconPickerService', () => {
|
||||
});
|
||||
|
||||
it('returns the icon selected by the dialog', async () => {
|
||||
dialogLauncherService.openIconPickerDialog.mockReturnValue({
|
||||
dialogLauncherService.openIconPickerDialog.mockResolvedValue({
|
||||
onClose: of({type: 'PRIME_NG', value: 'pi pi-book'}),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {EMPTY, from, Observable, switchMap} from 'rxjs';
|
||||
import {DialogLauncherService} from '../services/dialog-launcher.service';
|
||||
|
||||
export interface IconSelection {
|
||||
@@ -12,7 +12,13 @@ export class IconPickerService {
|
||||
private dialogLauncherService = inject(DialogLauncherService);
|
||||
|
||||
open(): Observable<IconSelection> {
|
||||
const ref = this.dialogLauncherService.openIconPickerDialog();
|
||||
return ref!.onClose as Observable<IconSelection>;
|
||||
return from(this.dialogLauncherService.openIconPickerDialog()).pipe(
|
||||
switchMap(ref => {
|
||||
if (!ref) {
|
||||
return EMPTY;
|
||||
}
|
||||
return ref.onClose as Observable<IconSelection>;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user