Files
angular-challenges/apps/ngrx-notification/src/app/app.config.ts
Alan Dragicevich 65f3d0e3d3 fix(ngrx-notification): compilation error
Due to upgrading to Angular 16,  `REDUCERS` were in the incorrect file and
should have been moved to `app.config.ts` from `main.ts`.
2023-07-06 08:36:24 +12:00

48 lines
1.4 KiB
TypeScript

import { ApplicationConfig } from '@angular/core';
import { provideStore } from '@ngrx/store';
import { provideEffects } from '@ngrx/effects';
import { TeacherEffects } from './teacher/store/teacher.effects';
import { StudentEffects } from './student/store/student.effects';
import { provideRouter } from '@angular/router';
import { ROUTES } from './routes';
import { APP_INITIALIZER, inject } from '@angular/core';
import { FakeBackendService } from '@angular-challenges/ngrx-notification/backend';
import { NotificationService } from './data-access/notification.service';
import {
teacherReducer,
teachersFeatureKey,
} from './teacher/store/teacher.reducer';
import {
studentReducer,
studentsFeatureKey,
} from './student/store/student.reducer';
const REDUCERS = {
[teachersFeatureKey]: teacherReducer,
[studentsFeatureKey]: studentReducer,
};
export const appConfig: ApplicationConfig = {
providers: [
provideStore(REDUCERS),
provideEffects([TeacherEffects, StudentEffects]),
provideRouter(ROUTES),
{
provide: APP_INITIALIZER,
multi: true,
useFactory: () => {
const service = inject(FakeBackendService);
return () => service.start();
},
},
{
provide: APP_INITIALIZER,
multi: true,
useFactory: () => {
const service = inject(NotificationService);
return () => service.init();
},
},
],
};