mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 14:01:20 +08:00
feat(module-loader): run outside of angular and in requestIdleCallback
This commit is contained in:
@ -594,7 +594,7 @@ export class IonicModule {
|
|||||||
{ provide: APP_INITIALIZER, useFactory: registerModeConfigs, deps: [ Config ], multi: true },
|
{ provide: APP_INITIALIZER, useFactory: registerModeConfigs, deps: [ Config ], multi: true },
|
||||||
{ provide: APP_INITIALIZER, useFactory: setupProvideEvents, deps: [ Platform, DomController ], 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: setupTapClick, deps: [ Config, Platform, DomController, App, NgZone, GestureController ], multi: true },
|
||||||
{ provide: APP_INITIALIZER, useFactory: setupPreloading, deps: [ Config, DeepLinkConfigToken, ModuleLoader ], multi: true },
|
{ provide: APP_INITIALIZER, useFactory: setupPreloading, deps: [ Config, DeepLinkConfigToken, ModuleLoader, NgZone ], multi: true },
|
||||||
|
|
||||||
// useClass
|
// useClass
|
||||||
// { provide: HAMMER_GESTURE_CONFIG, useClass: IonicGestureConfig },
|
// { provide: HAMMER_GESTURE_CONFIG, useClass: IonicGestureConfig },
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { ComponentFactoryResolver, Injectable, Injector, NgModuleFactory, OpaqueToken, Type } from '@angular/core';
|
import { ComponentFactoryResolver, Injectable, Injector, NgModuleFactory, NgZone, OpaqueToken, Type } from '@angular/core';
|
||||||
import { Config } from '../config/config';
|
import { Config } from '../config/config';
|
||||||
import { DeepLinkConfig } from '../navigation/nav-util';
|
import { DeepLinkConfig } from '../navigation/nav-util';
|
||||||
import { NgModuleLoader } from './ng-module-loader';
|
import { NgModuleLoader } from './ng-module-loader';
|
||||||
|
import { requestIonicCallback } from './util';
|
||||||
|
|
||||||
export const LAZY_LOADED_TOKEN = new OpaqueToken('LZYCMP');
|
export const LAZY_LOADED_TOKEN = new OpaqueToken('LZYCMP');
|
||||||
|
|
||||||
@ -76,8 +77,7 @@ export interface LoadedModule {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
export function setupPreloading(config: Config, deepLinkConfig: DeepLinkConfig, moduleLoader: ModuleLoader) {
|
export function setupPreloadingImplementation(config: Config, deepLinkConfig: DeepLinkConfig, moduleLoader: ModuleLoader) {
|
||||||
return function() {
|
|
||||||
if (config.getBoolean('preloadModules')) {
|
if (config.getBoolean('preloadModules')) {
|
||||||
const linksToLoad = deepLinkConfig.links.filter(link => !!link.loadChildren && link.priority !== 'off');
|
const linksToLoad = deepLinkConfig.links.filter(link => !!link.loadChildren && link.priority !== 'off');
|
||||||
|
|
||||||
@ -100,5 +100,17 @@ export function setupPreloading(config: Config, deepLinkConfig: DeepLinkConfig,
|
|||||||
console.error(err.message);
|
console.error(err.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export function setupPreloading(config: Config, deepLinkConfig: DeepLinkConfig, moduleLoader: ModuleLoader, ngZone: NgZone) {
|
||||||
|
return function() {
|
||||||
|
requestIonicCallback(() => {
|
||||||
|
ngZone.runOutsideAngular(() => {
|
||||||
|
setupPreloadingImplementation(config, deepLinkConfig, moduleLoader);
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user