Skip to content

Commit 3733ebc

Browse files
committed
feat(router): allow multiple routers
Custom routers could be add to update LocalStorage, API updates, database changes, etc.
1 parent 7679ac0 commit 3733ebc

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

ionic/components/nav/nav-controller.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {Ion} from '../ion';
66
import {IonicApp} from '../app/app';
77
import {Keyboard} from '../../util/keyboard';
88
import {NavParams} from './nav-params';
9-
import {NavRouter} from './nav-router';
10-
import {pascalCaseToDashCase, isTrueProperty, isBlank} from '../../util/util';
9+
import {pascalCaseToDashCase, isBlank} from '../../util/util';
1110
import {Portal} from './nav-portal';
1211
import {raf} from '../../util/dom';
1312
import {SwipeBackGesture} from './swipe-back';
@@ -131,7 +130,7 @@ export class NavController extends Ion {
131130
/**
132131
* @private
133132
*/
134-
router: NavRouter;
133+
routers: any[] = [];
135134

136135
/**
137136
* @private
@@ -1254,9 +1253,12 @@ export class NavController extends Ion {
12541253
this._app && this._app.setEnabled(true);
12551254
this.setTransitioning(false);
12561255

1257-
if (this.router && direction !== null && hasCompleted) {
1256+
if (direction !== null && hasCompleted && this._portal) {
12581257
// notify router of the state change if a direction was provided
1259-
this.router.stateChange(direction, enteringView);
1258+
// multiple routers can exist and each should be notified
1259+
this.routers.forEach(router => {
1260+
router.stateChange(direction, enteringView);
1261+
});
12601262
}
12611263

12621264
// see if we should add the swipe back gesture listeners or not
@@ -1630,10 +1632,9 @@ export class NavController extends Ion {
16301632

16311633
/**
16321634
* @private
1633-
* @param {TODO} router TODO
16341635
*/
1635-
registerRouter(router) {
1636-
this.router = router;
1636+
registerRouter(router: any) {
1637+
this.routers.push(router);
16371638
}
16381639

16391640
/**

0 commit comments

Comments
 (0)