Last active
March 10, 2019 11:11
-
-
Save phenomnomnominal/1533e03f8d9dd317f7f2a11ab77bfbb1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const ROUTES = new InjectionToken<Route[][]>('ROUTES'); | |
export class RouterConfigLoader { | |
// ... | |
load(parentInjector: Injector, route: Route): Observable<LoadedRouterConfig> { | |
// ... | |
const moduleFactory$ = this.loadModuleFactory(route.loadChildren !); | |
// ... | |
} | |
private loadModuleFactory(loadChildren: LoadChildren): Observable<NgModuleFactory<any>> { | |
if (typeof loadChildren === 'string') { | |
return from(this.loader.load(loadChildren)); | |
} else { | |
return wrapIntoObservable(loadChildren()).pipe(mergeMap((t: any) => { | |
if (t instanceof NgModuleFactory) { | |
return of (t); | |
} else { | |
return from(this.compiler.compileModuleAsync(t)); | |
} | |
})); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment