perf(router): prevent initializaing page twice

This commit is contained in:
Manu Mtz.-Almeida
2018-09-07 00:53:47 +02:00
parent fc87875b8f
commit 3dd9604f3e
2 changed files with 9 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
import { Component, Event, EventEmitter, Prop } from '@stencil/core';
import { Component, Event, EventEmitter, Prop, Watch } from '@stencil/core';
@Component({
tag: 'ion-route-redirect'
@@ -39,13 +39,16 @@ export class RouteRedirect {
*/
@Event() ionRouteRedirectChanged!: EventEmitter;
@Watch('from')
@Watch('to')
propDidChange() {
this.ionRouteRedirectChanged.emit();
}
componentDidLoad() {
this.ionRouteRedirectChanged.emit();
}
componentDidUnload() {
this.ionRouteRedirectChanged.emit();
}
componentDidUpdate() {
this.ionRouteRedirectChanged.emit();
}
}

View File

@@ -66,10 +66,11 @@ export class Router {
console.debug('[ion-router] found nav');
await this.onRoutesChanged();
}
componentDidLoad() {
this.win.addEventListener('ionRouteRedirectChanged', debounce(this.onRedirectChanged.bind(this), 10));
this.win.addEventListener('ionRouteDataChanged', debounce(this.onRoutesChanged.bind(this), 100));
this.onRedirectChanged();
}
@Listen('window:popstate')