// angular import { NgModule, ModuleWithProviders, Optional, SkipSelf } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; import { HttpModule } from '@angular/http'; // libs import { StoreModule } from '@ngrx/store'; import { StoreDevtoolsModule } from '@ngrx/store-devtools'; // module import { LOOP_COMPONENTS } from '../components/index'; import { LOOP_PROVIDERS } from '../services/index'; import { LOOP_DIRECTIVES } from '../directives/index'; import { LOOP_PIPES } from '../pipes/index'; import { AppReducer } from '../states/app.state'; /** * The primary shared Angular module for Loop * @author Sean Perkins * @export * @class LoopModule */ @NgModule({ imports: [ CommonModule, RouterModule, FormsModule, HttpModule, StoreModule.provideStore(AppReducer), StoreDevtoolsModule.instrumentOnlyWithExtension() ], declarations: [ LOOP_COMPONENTS, LOOP_DIRECTIVES, LOOP_PIPES ], exports: [ CommonModule, FormsModule, RouterModule, HttpModule, LOOP_COMPONENTS, LOOP_DIRECTIVES, LOOP_PIPES ], providers: [ LOOP_PROVIDERS ] }) export class LoopModule { static forRoot(configuredProviders: any[] = []): ModuleWithProviders { return { ngModule: LoopModule, providers: configuredProviders } } constructor(@Optional() @SkipSelf() parentModule: LoopModule) { if(parentModule) { throw new Error('LoopModule is already loaded; Import in root module only.'); } } }