Skip to content

Commit

Permalink
feat(router): allow multiple routers
Browse files Browse the repository at this point in the history
Custom routers could be add to update LocalStorage, API updates,
database changes, etc.
  • Loading branch information
adamdbradley committed Apr 5, 2016
1 parent 7679ac0 commit 3733ebc
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions ionic/components/nav/nav-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {Ion} from '../ion';
import {IonicApp} from '../app/app';
import {Keyboard} from '../../util/keyboard';
import {NavParams} from './nav-params';
import {NavRouter} from './nav-router';
import {pascalCaseToDashCase, isTrueProperty, isBlank} from '../../util/util';
import {pascalCaseToDashCase, isBlank} from '../../util/util';
import {Portal} from './nav-portal';
import {raf} from '../../util/dom';
import {SwipeBackGesture} from './swipe-back';
Expand Down Expand Up @@ -131,7 +130,7 @@ export class NavController extends Ion {
/**
* @private
*/
router: NavRouter;
routers: any[] = [];

This comment has been minimized.

Copy link
@manucorporat

manucorporat Apr 5, 2016

Contributor

routers: NavRouter[] = [];
?


/**
* @private
Expand Down Expand Up @@ -1254,9 +1253,12 @@ export class NavController extends Ion {
this._app && this._app.setEnabled(true);
this.setTransitioning(false);

if (this.router && direction !== null && hasCompleted) {
if (direction !== null && hasCompleted && this._portal) {
// notify router of the state change if a direction was provided
this.router.stateChange(direction, enteringView);
// multiple routers can exist and each should be notified
this.routers.forEach(router => {
router.stateChange(direction, enteringView);
});
}

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

/**
* @private
* @param {TODO} router TODO
*/
registerRouter(router) {
this.router = router;
registerRouter(router: any) {
this.routers.push(router);
}

/**
Expand Down

0 comments on commit 3733ebc

Please sign in to comment.