mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 13:32:54 +08:00
chore(module): set up preloading
This commit is contained in:
@ -33,7 +33,7 @@ import { Keyboard } from './platform/keyboard';
|
||||
import { LoadingController } from './components/loading/loading-controller';
|
||||
import { MenuController } from './components/menu/menu-controller';
|
||||
import { ModalController } from './components/modal/modal-controller';
|
||||
import { ModuleLoader, provideModuleLoader, LAZY_LOADED_TOKEN } from './util/module-loader';
|
||||
import { ModuleLoader, provideModuleLoader, setupPreloading, LAZY_LOADED_TOKEN } from './util/module-loader';
|
||||
import { NgModuleLoader } from './util/ng-module-loader';
|
||||
import { PickerController } from './components/picker/picker-controller';
|
||||
import { Platform, setupPlatform } from './platform/platform';
|
||||
@ -591,6 +591,7 @@ export class IonicModule {
|
||||
{ provide: APP_INITIALIZER, useFactory: registerModeConfigs, deps: [ Config ], multi: true },
|
||||
{ provide: APP_INITIALIZER, useFactory: setupProvideEvents, deps: [ Platform, DomController ], multi: true },
|
||||
{ provide: APP_INITIALIZER, useFactory: setupTapClick, deps: [ Config, Platform, DomController, App, NgZone, GestureController ], multi: true },
|
||||
{ provide: APP_INITIALIZER, useFactory: setupPreloading, deps: [ DeepLinkConfigToken, ModuleLoader ], multi: true },
|
||||
|
||||
// useClass
|
||||
// { provide: HAMMER_GESTURE_CONFIG, useClass: IonicGestureConfig },
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { ComponentFactoryResolver, Injectable, Injector, OpaqueToken, Type } from '@angular/core';
|
||||
import { DeepLinkConfig } from '../navigation/nav-util';
|
||||
import { NgModuleLoader } from './ng-module-loader';
|
||||
|
||||
export const LAZY_LOADED_TOKEN = new OpaqueToken('LZYCMP');
|
||||
@ -47,3 +48,16 @@ export interface LoadedModule {
|
||||
componentFactoryResolver: ComponentFactoryResolver;
|
||||
component: Type<any>;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export function setupPreloading(deeplinkConfig: DeepLinkConfig, moduleLoader: ModuleLoader) {
|
||||
return function() {
|
||||
const linksToLoad = deeplinkConfig.links.filter(link => !!link.loadChildren);
|
||||
for (const link of linksToLoad) {
|
||||
moduleLoader.load(link.loadChildren);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user