Skip to content

Commit

Permalink
Merge pull request #15 from ZEISS/CFWEB-85-NGRX_Standalone
Browse files Browse the repository at this point in the history
CFWEB-85 Use of NGRX Standalone API for application config and bootstrapping
  • Loading branch information
ssaring authored Dec 5, 2023
2 parents 75796de + 374b373 commit 11f0b36
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 45 deletions.
21 changes: 18 additions & 3 deletions src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,26 @@

import { ApplicationConfig, importProvidersFrom } from '@angular/core';
import { provideRouter } from '@angular/router';

import { routes } from './app.routes';
import { StoreModule } from '@store/store.module';
import { CatalogModule } from '@app/catalog/catalog.module';
import { provideStore } from '@ngrx/store';
import { metaReducers, reducers } from '@app/reducers';
import { provideStoreDevtools } from '@ngrx/store-devtools';
import { environment } from '@environment';
import { provideEffects } from '@ngrx/effects';
import { NavigationEffects } from '@app/shared/navigation/navigation.effects';

const storeProviders = [
provideStore(reducers, {
metaReducers,
}),
provideStoreDevtools({
maxAge: 25,
logOnly: environment.production,
}),
provideEffects(NavigationEffects),
];

export const appConfig: ApplicationConfig = {
providers: [importProvidersFrom(StoreModule, CatalogModule), provideRouter(routes)],
providers: [importProvidersFrom(CatalogModule), provideRouter(routes), storeProviders],
};
11 changes: 3 additions & 8 deletions src/app/catalog/catalog.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { StoreModule } from '@ngrx/store';
import { provideState } from '@ngrx/store';
import { RecommendationModule } from '@app/catalog/recommendation/recommendation.module';
import { ProductModule } from '@app/catalog/product/product.module';
import { reducer, catalogFeatureKey } from '@app/catalog/store/catalog.reducer';
import { CatalogRoutingModule } from '@app/catalog/catalog-routing.module';

@NgModule({
declarations: [],
imports: [
CommonModule,
ProductModule,
CatalogRoutingModule,
RecommendationModule,
StoreModule.forFeature(catalogFeatureKey, reducer),
],
imports: [CommonModule, ProductModule, CatalogRoutingModule, RecommendationModule],
providers: [provideState(catalogFeatureKey, reducer)],
})
export class CatalogModule {}
5 changes: 2 additions & 3 deletions src/app/catalog/product/product.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { EffectsModule } from '@ngrx/effects';
import { provideEffects } from '@ngrx/effects';

import { ProductDetailComponent } from '@app/catalog/product/components/product-detail/product-detail.component';
import { ProductMasterComponent } from '@app/catalog/product/components/product-master/product-master.component';
Expand All @@ -23,10 +23,9 @@ import { ProductComponent } from '@app/shared/components/product/product.compone
RecommendationModule,
ProductComponent,
ThemeSwitcherComponent,
EffectsModule.forFeature([ProductEffects]),
],
declarations: [ProductDetailComponent, ProductMasterComponent],
exports: [ProductDetailComponent, ProductMasterComponent],
providers: [ProductService],
providers: [ProductService, provideEffects(ProductEffects)],
})
export class ProductModule {}
10 changes: 3 additions & 7 deletions src/app/catalog/recommendation/recommendation.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@

import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { EffectsModule } from '@ngrx/effects';
import { provideEffects } from '@ngrx/effects';

import { RecommendationsComponent } from '@app/catalog/recommendation/components/recommendations/recommendations.component';
import { RecommendationService } from '@app/catalog/recommendation/services/recommendation.service';
import { RecommendationEffects } from '@app/catalog/recommendation/store/recommendation.effects';
import { RecommendationComponent } from '@app/shared/components/recommendation/recommendation.component';

@NgModule({
imports: [
CommonModule,
RecommendationComponent,
EffectsModule.forFeature([RecommendationEffects]),
],
imports: [CommonModule, RecommendationComponent],
declarations: [RecommendationsComponent],
exports: [RecommendationsComponent],
providers: [RecommendationService],
providers: [RecommendationService, provideEffects(RecommendationEffects)],
})
export class RecommendationModule {}
24 changes: 0 additions & 24 deletions src/support/store/store.module.ts

This file was deleted.

0 comments on commit 11f0b36

Please sign in to comment.