62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import {
|
|
NgModule,
|
|
Inject,
|
|
APP_BOOTSTRAP_LISTENER,
|
|
InjectionToken, Type,
|
|
} from '@angular/core';
|
|
import { BrowserModule } from '@angular/platform-browser';
|
|
|
|
import { AppComponent } from './app.component';
|
|
import { AppContentComponent } from './app-content.component';
|
|
import { AppSidePanelTestComponent } from './app-side-panel-test.component';
|
|
import { AppCommonModule } from '@farmmaps/common';
|
|
|
|
import {StoreModule, Store} from '@ngrx/store';
|
|
import {EffectsModule, EffectSources} from '@ngrx/effects';
|
|
import { StoreRouterConnectingModule} from '@ngrx/router-store';
|
|
|
|
import {AppRoutingModule} from './app-routing.module';
|
|
|
|
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: [
|
|
AppComponent,
|
|
AppContentComponent,
|
|
AppSidePanelTestComponent
|
|
],
|
|
imports: [
|
|
AppRoutingModule,
|
|
AppCommonModule.forRoot() ,
|
|
BrowserModule,
|
|
StoreModule.forRoot({}),
|
|
EffectsModule.forRoot([])
|
|
],
|
|
providers: [],
|
|
bootstrap: [AppComponent]
|
|
})
|
|
export class AppModule { }
|