@@ -45,6 +45,7 @@ class Router extends React.Component {
4545
4646 this . onForward = this . onForward . bind ( this ) ;
4747 this . onBack = this . onBack . bind ( this ) ;
48+ this . onPopToRoute = this . onPopToRoute . bind ( this ) ;
4849 this . onReplaceRoute = this . onReplaceRoute . bind ( this ) ;
4950 this . onResetToRoute = this . onResetToRoute . bind ( this ) ;
5051 this . onToFirstRoute = this . onToFirstRoute . bind ( this ) ;
@@ -54,6 +55,9 @@ class Router extends React.Component {
5455 this . onWillPop = this . onWillPop . bind ( this ) ;
5556 this . onDidPop = this . onDidPop . bind ( this ) ;
5657
58+ this . onWillPopToRoute = this . onWillPopToRoute . bind ( this ) ;
59+ this . onDidPopToRoute = this . onDidPopToRoute . bind ( this ) ;
60+
5761 this . onWillPush = this . onWillPush . bind ( this ) ;
5862 this . onDidPush = this . onDidPush . bind ( this ) ;
5963
@@ -98,6 +102,13 @@ class Router extends React.Component {
98102 this . onDidPop ( ) ;
99103 } ) ;
100104
105+ aspect . before ( this . refs . navigator , 'popToRoute' , ( ) => {
106+ this . onWillPopToRoute ( ) ;
107+ } ) ;
108+ aspect . after ( this . refs . navigator , 'popToRoute' , ( ) => {
109+ this . onDidPopToRoute ( ) ;
110+ } ) ;
111+
101112 aspect . before ( this . refs . navigator , 'push' , ( route ) => {
102113 this . onWillPush ( route ) ;
103114 } ) ;
@@ -142,6 +153,12 @@ class Router extends React.Component {
142153 }
143154 }
144155
156+ onPopToRoute ( nextRoute , navigator ) {
157+ navigator . popToRoute (
158+ Object . assign ( nextRoute )
159+ ) ;
160+ }
161+
145162 onReplaceRoute ( nextRoute , navigator ) {
146163 navigator . replace (
147164 Object . assign ( nextRoute , { index : this . state . route . index || 0 } )
@@ -166,6 +183,14 @@ class Router extends React.Component {
166183 this . emitter . emit ( 'didPop' ) ;
167184 }
168185
186+ onWillPopToRoute ( ) {
187+ this . emitter . emit ( 'willPopToRoute' ) ;
188+ }
189+
190+ onDidPopToRoute ( ) {
191+ this . emitter . emit ( 'didPopToRoute' ) ;
192+ }
193+
169194 onWillPush ( route ) {
170195 this . emitter . emit ( 'willPush' , route ) ;
171196 }
@@ -224,6 +249,11 @@ class Router extends React.Component {
224249 this . emitter . emit ( 'push' , nextRoute ) ;
225250 } ;
226251
252+ const popToRoute = ( nextRoute ) => {
253+ this . onPopToRoute ( nextRoute , navigator ) ;
254+ this . emitter . emit ( 'popToRoute' , nextRoute ) ;
255+ } ;
256+
227257 const replaceRoute = ( nextRoute ) => {
228258 this . onReplaceRoute ( nextRoute , navigator ) ;
229259 this . emitter . emit ( 'replace' , nextRoute ) ;
@@ -278,6 +308,7 @@ class Router extends React.Component {
278308
279309 this . toRoute = goForward ;
280310 this . toBack = goBackwards ;
311+ this . popToRoute = popToRoute ;
281312 this . replaceRoute = replaceRoute ;
282313 this . resetToRoute = resetToRoute ;
283314 this . reset = goToFirstRoute ;
@@ -296,6 +327,7 @@ class Router extends React.Component {
296327 data = { route . data }
297328 toRoute = { goForward }
298329 toBack = { goBackwards }
330+ popToRoute = { popToRoute }
299331 routeEmitter = { this . emitter }
300332 replaceRoute = { replaceRoute }
301333 resetToRoute = { resetToRoute }
@@ -328,6 +360,7 @@ class Router extends React.Component {
328360 borderColor = { this . props . borderColor }
329361 toRoute = { this . onForward }
330362 toBack = { this . onBack }
363+ popToRoute = { this . onPopToRoute }
331364 replaceRoute = { this . onReplaceRoute }
332365 resetToRoute = { this . onResetToRoute }
333366 goToFirstRoute = { this . onToFirstRoute }
0 commit comments