FarmMapsLib/src/app/app.module.ts

86 lines
2.5 KiB
TypeScript
Raw Normal View History

2019-11-13 10:46:23 +00:00
import {
NgModule,
Inject,
APP_BOOTSTRAP_LISTENER,
InjectionToken, Type,
} from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
2019-12-19 12:41:59 +00:00
import { AppCommonModule,AppCommonServiceModule,AuthConfigFactory } from '@farmmaps/common';
2019-11-13 10:46:23 +00:00
import { AppCommonMapModule} from '@farmmaps/common-map';
import {AppRootComponent} from './app.component';
import {StoreModule, Store} from '@ngrx/store';
import {EffectsModule, EffectSources} from '@ngrx/effects';
import { StoreRouterConnectingModule} from '@ngrx/router-store';
import {AppRoutingModule} from './app-routing.module';
import { LogoComponent } from './logo/logo.component';
import { MenuComponent } from './menu/menu.component';
2020-02-04 13:20:32 +00:00
import {RegisterDeviceComponent} from './registerdevice/registerdevice.component';
2020-01-22 10:33:33 +00:00
import { SecureOAuthStorage} from '@farmmaps/common';
import { OAuthStorage } from 'angular-oauth2-oidc';
2020-02-12 20:34:11 +00:00
import {Id4AuthconfigFactory} from './id4AuthconfigFactory';
2019-11-13 10:46:23 +00:00
export const BOOTSTRAP_EFFECTS = new InjectionToken('Bootstrap Effects');
export function bootstrapEffects(effects: Type<any>[], sources: EffectSources) {
return () => {
effects.forEach(effect => sources.addEffects(effect));
};
}
export function createInstances(...instances: any[]) {
return instances;
}
export function provideBootstrapEffects(effects: Type<any>[]) {
return [
effects,
{provide: BOOTSTRAP_EFFECTS, deps: effects, useFactory: createInstances},
{
provide: APP_BOOTSTRAP_LISTENER,
multi: true,
useFactory: bootstrapEffects,
deps: [[new Inject(BOOTSTRAP_EFFECTS)], EffectSources],
},
];
}
@NgModule({
declarations: [
AppRootComponent,
LogoComponent,
2020-02-04 13:20:32 +00:00
MenuComponent,
RegisterDeviceComponent
2019-11-13 10:46:23 +00:00
],
imports: [
AppRoutingModule,
AppCommonModule,
AppCommonServiceModule.forRoot(),
AppCommonMapModule.forRoot(),
BrowserModule,
2020-04-01 14:11:44 +00:00
StoreModule.forRoot({},{runtimeChecks: { // TODO fix this should all be true
strictStateImmutability: false,
strictActionImmutability: false,
strictStateSerializability: false,
strictActionSerializability: false
}}),
2019-11-13 10:46:23 +00:00
EffectsModule.forRoot([])
],
2019-12-19 12:41:59 +00:00
providers: [
2020-01-22 10:33:33 +00:00
AuthConfigFactory,
{
provide:OAuthStorage,
useClass:SecureOAuthStorage
},
{
provide:AuthConfigFactory,
useClass:Id4AuthconfigFactory
}
2019-12-19 12:41:59 +00:00
],
2019-11-13 10:46:23 +00:00
bootstrap: [AppRootComponent]
})
export class AppModule { }