@@ -45,6 +45,7 @@ class Router extends React.Component {
45
45
46
46
this . onForward = this . onForward . bind ( this ) ;
47
47
this . onBack = this . onBack . bind ( this ) ;
48
+ this . onPopToRoute = this . onPopToRoute . bind ( this ) ;
48
49
this . onReplaceRoute = this . onReplaceRoute . bind ( this ) ;
49
50
this . onResetToRoute = this . onResetToRoute . bind ( this ) ;
50
51
this . onToFirstRoute = this . onToFirstRoute . bind ( this ) ;
@@ -54,6 +55,9 @@ class Router extends React.Component {
54
55
this . onWillPop = this . onWillPop . bind ( this ) ;
55
56
this . onDidPop = this . onDidPop . bind ( this ) ;
56
57
58
+ this . onWillPopToRoute = this . onWillPopToRoute . bind ( this ) ;
59
+ this . onDidPopToRoute = this . onDidPopToRoute . bind ( this ) ;
60
+
57
61
this . onWillPush = this . onWillPush . bind ( this ) ;
58
62
this . onDidPush = this . onDidPush . bind ( this ) ;
59
63
@@ -98,6 +102,13 @@ class Router extends React.Component {
98
102
this . onDidPop ( ) ;
99
103
} ) ;
100
104
105
+ aspect . before ( this . refs . navigator , 'popToRoute' , ( ) => {
106
+ this . onWillPopToRoute ( ) ;
107
+ } ) ;
108
+ aspect . after ( this . refs . navigator , 'popToRoute' , ( ) => {
109
+ this . onDidPopToRoute ( ) ;
110
+ } ) ;
111
+
101
112
aspect . before ( this . refs . navigator , 'push' , ( route ) => {
102
113
this . onWillPush ( route ) ;
103
114
} ) ;
@@ -142,6 +153,12 @@ class Router extends React.Component {
142
153
}
143
154
}
144
155
156
+ onPopToRoute ( nextRoute , navigator ) {
157
+ navigator . popToRoute (
158
+ Object . assign ( nextRoute )
159
+ ) ;
160
+ }
161
+
145
162
onReplaceRoute ( nextRoute , navigator ) {
146
163
navigator . replace (
147
164
Object . assign ( nextRoute , { index : this . state . route . index || 0 } )
@@ -166,6 +183,14 @@ class Router extends React.Component {
166
183
this . emitter . emit ( 'didPop' ) ;
167
184
}
168
185
186
+ onWillPopToRoute ( ) {
187
+ this . emitter . emit ( 'willPopToRoute' ) ;
188
+ }
189
+
190
+ onDidPopToRoute ( ) {
191
+ this . emitter . emit ( 'didPopToRoute' ) ;
192
+ }
193
+
169
194
onWillPush ( route ) {
170
195
this . emitter . emit ( 'willPush' , route ) ;
171
196
}
@@ -224,6 +249,11 @@ class Router extends React.Component {
224
249
this . emitter . emit ( 'push' , nextRoute ) ;
225
250
} ;
226
251
252
+ const popToRoute = ( nextRoute ) => {
253
+ this . onPopToRoute ( nextRoute , navigator ) ;
254
+ this . emitter . emit ( 'popToRoute' , nextRoute ) ;
255
+ } ;
256
+
227
257
const replaceRoute = ( nextRoute ) => {
228
258
this . onReplaceRoute ( nextRoute , navigator ) ;
229
259
this . emitter . emit ( 'replace' , nextRoute ) ;
@@ -278,6 +308,7 @@ class Router extends React.Component {
278
308
279
309
this . toRoute = goForward ;
280
310
this . toBack = goBackwards ;
311
+ this . popToRoute = popToRoute ;
281
312
this . replaceRoute = replaceRoute ;
282
313
this . resetToRoute = resetToRoute ;
283
314
this . reset = goToFirstRoute ;
@@ -296,6 +327,7 @@ class Router extends React.Component {
296
327
data = { route . data }
297
328
toRoute = { goForward }
298
329
toBack = { goBackwards }
330
+ popToRoute = { popToRoute }
299
331
routeEmitter = { this . emitter }
300
332
replaceRoute = { replaceRoute }
301
333
resetToRoute = { resetToRoute }
@@ -328,6 +360,7 @@ class Router extends React.Component {
328
360
borderColor = { this . props . borderColor }
329
361
toRoute = { this . onForward }
330
362
toBack = { this . onBack }
363
+ popToRoute = { this . onPopToRoute }
331
364
replaceRoute = { this . onReplaceRoute }
332
365
resetToRoute = { this . onResetToRoute }
333
366
goToFirstRoute = { this . onToFirstRoute }
0 commit comments