feat(core): upgrade rxjs to 6.0.0-alpha.4 (#22573)

PR Close #22573
This commit is contained in:
Igor Minar
2018-02-27 17:06:06 -05:00
parent c445314239
commit b43f8bc7d3
270 changed files with 10104 additions and 1860 deletions

View File

@ -6,12 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Compiler, InjectionToken, Injector, NgModuleFactory, NgModuleFactoryLoader, NgModuleRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {fromPromise} from 'rxjs/observable/fromPromise';
import {of } from 'rxjs/observable/of';
import {map} from 'rxjs/operator/map';
import {mergeMap} from 'rxjs/operator/mergeMap';
import {Compiler, InjectionToken, Injector, NgModuleFactory, NgModuleFactoryLoader} from '@angular/core';
// TODO(i): switch to fromPromise once it's expored in rxjs
import {Observable, from, of } from 'rxjs';
import {map, mergeMap} from 'rxjs/operators';
import {LoadChildren, LoadedRouterConfig, Route, copyConfig} from './config';
import {flatten, wrapIntoObservable} from './utils/collection';
@ -34,7 +32,7 @@ export class RouterConfigLoader {
const moduleFactory$ = this.loadModuleFactory(route.loadChildren !);
return map.call(moduleFactory$, (factory: NgModuleFactory<any>) => {
return moduleFactory$.pipe(map((factory: NgModuleFactory<any>) => {
if (this.onLoadEndListener) {
this.onLoadEndListener(route);
}
@ -42,20 +40,20 @@ export class RouterConfigLoader {
const module = factory.create(parentInjector);
return new LoadedRouterConfig(flatten(module.injector.get(ROUTES)).map(copyConfig), module);
});
}));
}
private loadModuleFactory(loadChildren: LoadChildren): Observable<NgModuleFactory<any>> {
if (typeof loadChildren === 'string') {
return fromPromise(this.loader.load(loadChildren));
return from(this.loader.load(loadChildren));
} else {
return mergeMap.call(wrapIntoObservable(loadChildren()), (t: any) => {
return wrapIntoObservable(loadChildren()).pipe(mergeMap((t: any) => {
if (t instanceof NgModuleFactory) {
return of (t);
} else {
return fromPromise(this.compiler.compileModuleAsync(t));
return from(this.compiler.compileModuleAsync(t));
}
});
}));
}
}
}