1 import { NgModule, ApplicationRef } from '@angular/core';
2 import { BrowserModule } from '@angular/platform-browser';
3 import { FormsModule, ReactiveFormsModule } from '@angular/forms';
4 import { HttpModule, RequestOptions, XHRBackend } from '@angular/http';
5 import { RouterModule } from '@angular/router';
6 import { removeNgStyles, createNewHosts } from '@angularclass/hmr';
8 import { FileSelectDirective } from 'ng2-file-upload/ng2-file-upload';
9 import { ProgressbarModule } from 'ng2-bootstrap/components/progressbar';
10 import { PaginationModule } from 'ng2-bootstrap/components/pagination';
11 import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
14 * Platform and Environment providers/directives/pipes
16 import { ENV_PROVIDERS } from './environment';
17 import { routes } from './app.routes';
18 // App is our top level component
19 import { AppComponent } from './app.component';
20 import { AppState } from './app.service';
21 import { AccountComponent, AccountService } from './account';
22 import { LoginComponent } from './login';
28 VideoMiniatureComponent,
46 import { MenuComponent } from './menu.component';
47 import { AuthService, AuthHttp, RestExtractor, RestService, SearchComponent, SearchService } from './shared';
49 // Application wide providers
50 const APP_PROVIDERS = [
55 useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => {
56 return new AuthHttp(backend, defaultOptions, authService);
58 deps: [ XHRBackend, RequestOptions, AuthService ]
63 RestExtractor, RestService, VideoService, SearchService, FriendService, UserService, AccountService, WebTorrentService
66 * `AppModule` is the main entry point into Angular2's bootstraping process
69 bootstrap: [ AppComponent ],
81 VideoMiniatureComponent,
94 imports: [ // import Angular's modules
99 RouterModule.forRoot(routes),
103 providers: [ // expose our Services and Providers into Angular's dependency injection
108 export class AppModule {
109 constructor(public appRef: ApplicationRef, public appState: AppState) {}
111 if (!store || !store.state) return;
112 console.log('HMR store', store);
113 this.appState._state = store.state;
117 hmrOnDestroy(store) {
118 const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
120 const state = this.appState._state;
122 store.disposeOldHosts = createNewHosts(cmpLocation);
126 hmrAfterDestroy(store) {
127 // display new elements
128 store.disposeOldHosts();
129 delete store.disposeOldHosts;