Permalink
Browse files

fix(module-loader): null references

  • Loading branch information...
manucorporat committed May 1, 2017
1 parent 45e71a6 commit 2afc5cfeda96a822f0dce5c7aa289002ebae8bd1
Showing with 17 additions and 15 deletions.
  1. +17 −15 src/util/module-loader.ts
View
@@ -75,24 +75,26 @@ export interface LoadedModule {
* @hidden
*/
export function setupPreloadingImplementation(config: Config, deepLinkConfig: DeepLinkConfig, moduleLoader: ModuleLoader): Promise<any> {
if (config.getBoolean('preloadModules') && deepLinkConfig && deepLinkConfig.links) {
const linksToLoad = deepLinkConfig.links.filter(link => !!link.loadChildren && link.priority !== 'off');
if (!deepLinkConfig || !deepLinkConfig.links || !config.getBoolean('preloadModules')) {
return Promise.resolve();
}
const linksToLoad = deepLinkConfig.links.filter(link => !!link.loadChildren && link.priority !== 'off');
// Load the high priority modules first
const highPriorityPromises = linksToLoad
.filter(link => link.priority === 'high')
.map(link => moduleLoader.load(link.loadChildren));
// Load the high priority modules first
const highPriorityPromises = linksToLoad.filter(link => link.priority === 'high')
return Promise.all(highPriorityPromises).then(() => {
// Load the low priority modules after the high priority are done
const lowPriorityPromises = linksToLoad
.filter(link => link.priority === 'low')
.map(link => moduleLoader.load(link.loadChildren));
return Promise.all(highPriorityPromises).then(() => {
// Load the low priority modules after the high priority are done
const lowPriorityPromises = linksToLoad.filter(link => link.priority === 'low')
.map(link => moduleLoader.load(link.loadChildren));
return Promise.all(lowPriorityPromises);
}).catch(err => {
console.error(err.message);
});
} else {
return Promise.resolve();
}
return Promise.all(lowPriorityPromises);
}).catch(err => {
console.error(err.message);
});
}
/**

0 comments on commit 2afc5cf

Please sign in to comment.