Closed msibhuiyan closed 4 months ago
Thanks @BhuiyanSaif18 for this PR.
Any chance for a migration guide from how it used to work with Module vs how to use it now? I've having a hard time understanding this change...
Any chance for a migration guide from how it used to work with Module vs how to use it now? I've having a hard time understanding this change...
Hi @HarelM, This PR added support for new service registration approach in ApplicationConfig. Previously we used to configure our NgModule like this
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HttpClientModule,
NgIdleKeepaliveModule.forRoot() // use NgIdleModule.forRoot() if not using keepalive
// We registered the NgIdle modules here.
],
providers: [],
bootstrap: [AppComponent]
})
Now in the new ApplicationConfig approach we register the NgIdle services like this & remove the NgIdleKeepaliveModule.forRoot()
from NgModules.
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
provideNgIdleKeepalive(), // use provideNgIdle() if not using keepalive
// We are registering NgIdle services here
provideHttpClient(withFetch())
]
};
Now this ApplicationConfig allows us to register the service at root level, we can move service registration to component level with provideNgIdleKeepalive()
, provideNgIdle()
by using the providers array of component or route.
Please do let me know if you need more clarifications.
Thanks for the info! This was very helpful.
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x")
What is the current behavior? (You can also link to an open issue here)
What is the new behavior?
Does this PR introduce a breaking change? (check one with "x")
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
Other information: Although this PR helped us to use with standalone component, but the old NgModule approach is still available to use.