import { ModuleWithProviders , NgModule , Optional , SkipSelf } from '@angular/core' ; import { AuthService } from './auth.service' ; import { UserService } from './user.service' ; import { AuthGuardService } from './auth-guard.service' ; import { HttpModule } from '@angular/http' ; import { StoreModule } from '@ngrx/store' ; import { todoReducer , todoFilterReducer } from '../reducers/todo.reducer' ; import { authReducer } from '../reducers/auth.reducer' ; import { StoreDevtoolsModule } from '@ngrx/store-devtools' ; @ NgModule ( { imports : [ HttpModule , StoreModule . provideStore ( { todos : todoReducer , todoFilter : todoFilterReducer , auth : authReducer } ) , StoreDevtoolsModule . instrumentOnlyWithExtension ( ) ] , providers : [ AuthService , UserService , AuthGuardService ] } ) export class CoreModule { constructor ( @ Optional ( ) @ SkipSelf ( ) parentModule ) { if ( parentModule ) { throw new Error ( 'CoreModule is already loaded. Import it in the AppModule only' ) ; } } }