Compare commits
2 Commits
6367d3399d
...
fb8129148d
Author | SHA1 | Date | |
---|---|---|---|
|
fb8129148d | ||
|
73db03148a |
@ -30,6 +30,7 @@ import { NgbDateNativeAdapter } from './services/date-adapter.service'
|
|||||||
import { AuthConfigFactory } from './shared/authconfigFactory';
|
import { AuthConfigFactory } from './shared/authconfigFactory';
|
||||||
import { StateSerializerService } from './services/state-serializer.service';
|
import { StateSerializerService } from './services/state-serializer.service';
|
||||||
import { PackageService } from './services/package.service';
|
import { PackageService } from './services/package.service';
|
||||||
|
import { PackagePreloadStartegy } from './services/package-preload-strategy.service';
|
||||||
import { SenmlService } from './services/senml-service';
|
import { SenmlService } from './services/senml-service';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@ -53,7 +54,8 @@ export {
|
|||||||
StateSerializerService,
|
StateSerializerService,
|
||||||
SchemaService,
|
SchemaService,
|
||||||
PackageService,
|
PackageService,
|
||||||
SenmlService
|
SenmlService,
|
||||||
|
PackagePreloadStartegy
|
||||||
};
|
};
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
import { Injectable} from '@angular/core';
|
||||||
|
import { PreloadingStrategy,Route } from '@angular/router'
|
||||||
|
import { Observable, EMPTY } from 'rxjs';
|
||||||
|
import { PackageService} from './package.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class PackagePreloadStartegy extends PreloadingStrategy {
|
||||||
|
|
||||||
|
loading = new Set<Route>();
|
||||||
|
|
||||||
|
constructor(private packageService$:PackageService) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
preload(route: Route, load: Function): Observable<any> {
|
||||||
|
if (this.loading.has(route)) {
|
||||||
|
// Don't preload the same route twice
|
||||||
|
return EMPTY;
|
||||||
|
}
|
||||||
|
if(route.data && route.data.package) {
|
||||||
|
if(this.packageService$.hasPackage(route.data.package)) {
|
||||||
|
console.debug(`Load module for package ${route.data.package}`)
|
||||||
|
this.loading.add(route);
|
||||||
|
return load()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return EMPTY;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user