@@ -6,6 +6,7 @@ import {RouteRegistry} from './route_registry';
66import  { Pipeline }  from  './pipeline' ; 
77import  { Instruction }  from  './instruction' ; 
88import  { RouterOutlet }  from  './router_outlet' ; 
9+ import  { Location }  from  './location' ; 
910
1011/** 
1112 * # Router 
@@ -28,17 +29,21 @@ export class Router {
2829 _outlets :Map < any ,  RouterOutlet > ; 
2930 _children :Map < any ,  Router > ; 
3031 _subject :EventEmitter ; 
31- 
32-  constructor ( registry :RouteRegistry ,  pipeline :Pipeline ,  parent :Router  =  null ,  name  =  '/' )  { 
32+  _location :Location ; 
33+  
34+  constructor ( registry :RouteRegistry ,  pipeline :Pipeline ,  location :Location ,  parent :Router  =  null ,  name  =  '/' )  { 
3335 this . name  =  name ; 
3436 this . navigating  =  false ; 
3537 this . parent  =  parent ; 
3638 this . previousUrl  =  null ; 
3739 this . _outlets  =  MapWrapper . create ( ) ; 
3840 this . _children  =  MapWrapper . create ( ) ; 
41+  this . _location  =  location ; 
3942 this . _registry  =  registry ; 
4043 this . _pipeline  =  pipeline ; 
4144 this . _subject  =  new  EventEmitter ( ) ; 
45+  this . _location . subscribe ( ( url )  =>  this . navigate ( url ) ) ; 
46+  this . navigate ( location . path ( ) ) ; 
4247 } 
4348
4449
@@ -97,6 +102,9 @@ export class Router {
97102 this . _startNavigating ( ) ; 
98103
99104 var  result  =  this . _pipeline . process ( instruction ) 
105+  . then ( ( _ )  =>  { 
106+  this . _location . go ( instruction . matchedUrl ) ; 
107+  } ) 
100108 . then ( ( _ )  =>  { 
101109 ObservableWrapper . callNext ( this . _subject ,  instruction . matchedUrl ) ; 
102110 } ) 
@@ -170,19 +178,19 @@ export class Router {
170178 } 
171179
172180 static  getRoot ( ) :Router  { 
173-  return  new  RootRouter ( new  Pipeline ( ) ) ; 
181+  return  new  RootRouter ( new  Pipeline ( ) ,   new   Location ( ) ) ; 
174182 } 
175183} 
176184
177185export  class  RootRouter  extends  Router  { 
178-  constructor ( pipeline :Pipeline )  { 
179-  super ( new  RouteRegistry ( ) ,  pipeline ,  null ,  '/' ) ; 
186+  constructor ( pipeline :Pipeline ,   location : Location )  { 
187+  super ( new  RouteRegistry ( ) ,  pipeline ,  location ,   null ,  '/' ) ; 
180188 } 
181189} 
182190
183191class  ChildRouter  extends  Router  { 
184192 constructor ( parent ,  name )  { 
185-  super ( parent . _registry ,  parent . _pipeline ,  parent ,  name ) ; 
193+  super ( parent . _registry ,  parent . _pipeline ,  parent . _location ,   parent ,  name ) ; 
186194 this . parent  =  parent ; 
187195 } 
188196} 
0 commit comments