mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
perf(router): prevent initializaing page twice
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user