Skip to content

Commit

Permalink
fix(v19): provide primeng (#17043)
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-peruzzo authored Dec 16, 2024
1 parent 88b6883 commit 07bf7ab
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/primeng/src/config/provideprimeng.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APP_INITIALIZER, EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core';
import { EnvironmentProviders, inject, InjectionToken, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';
import { PrimeNG, PrimeNGConfigType } from './primeng';

export const PRIME_NG_CONFIG = new InjectionToken<PrimeNGConfigType>('PRIME_NG_CONFIG');
Expand All @@ -10,13 +10,11 @@ export function providePrimeNG(...features: PrimeNGConfigType[]): EnvironmentPro
multi: false
}));

// @todo: use provideAppInitializer in v19
const initializer = {
provide: APP_INITIALIZER,
useFactory: (PrimeNGConfig: PrimeNG) => () => features?.forEach((feature) => PrimeNGConfig.setConfig(feature)),
deps: [PrimeNG],
multi: true
};
const initializer = provideAppInitializer(() => {
const PrimeNGConfig = inject(PrimeNG);
features?.forEach((feature) => PrimeNGConfig.setConfig(feature));
return;
});

return makeEnvironmentProviders([...providers, initializer]);
}

0 comments on commit 07bf7ab

Please sign in to comment.