Do you know any way to implement the Bottom Navigation plugin with Lazy Loading?
I will explain a bit about my scenario.
I choose to call the components (TabOne, etc) in this way because it will keep the state after you change the tab. With routing, the tab is destroyed when I go to another tab and initiated again when I go back. I needed a way to keep the state of the tab and this was the only one. (If you have another idea, feel free to explain it).
home.module
@NgModule({
imports: [
...
TabOneModule,
TabTwoModule,
TabThreeModule,
],
})
home.component.ts
public bottomBar: BottomBarObject = {
structure: [],
tabs: [],
selectedIndex: 0
};
constructor(...) {
this.bottomBar.structure = [...];
this.bottomBar.tabs = this.bottomBar.structure.map(tab => {
return new BottomNavigationTab(tab.title, tab.icon, tab.selectable);
});
}
tabSelected(args: OnTabSelectedEventData): void {
if (args.newIndex !== args.oldIndex) {
console.log(`bottomBar tabSelected : ${args.newIndex}`);
this.bottomBar.selectedIndex = args.newIndex;
...<some more logics>
}
}
home.component.html
<BottomNavigation [tabs]="bottomBar.tabs" (tabSelected)="tabSelected($event)"></BottomNavigation>
<StackLayout [ngSwitch]="bottomBar.selectedIndex">
<app-tabone *ngSwitchCase="0"></app-tabone>
<app-tabtwo *ngSwitchCase="1"></app-tabtwo>
<app-tabthree *ngSwitchCase="2"></app-tabthree>
</StackLayout>
It works perfectly in this way.
My problem
The problem appears when I wanted to do some performance improvements in startup time and I realized that for home.module I have to load all the other modules included in BottomBar (TabOneModule, TabTwoModule, etc) even if the user, probably, do not use one of them (let's say TabThreeModule).
I would like to know if there is any way to implement Lazy Loading for this scenario where I can lazy load one of my module inside of Bottom Bar manually when tabSelected is triggered.
Any idea?
Do you know any way to implement the Bottom Navigation plugin with Lazy Loading?
I will explain a bit about my scenario.
I choose to call the components (
TabOne, etc) in this way because it will keep the state after you change the tab. With routing, the tab is destroyed when I go to another tab and initiated again when I go back. I needed a way to keep the state of the tab and this was the only one. (If you have another idea, feel free to explain it).home.module
home.component.ts
home.component.html
It works perfectly in this way.
My problem
The problem appears when I wanted to do some performance improvements in startup time and I realized that for
home.moduleI have to load all the other modules included in BottomBar (TabOneModule, TabTwoModule, etc) even if the user, probably, do not use one of them (let's say TabThreeModule).I would like to know if there is any way to implement Lazy Loading for this scenario where I can lazy load one of my module inside of Bottom Bar manually when
tabSelectedis triggered.Any idea?