Skip to content

Commit fd2c061

Browse files
committed
Add a callback which gets called when we have a page ready. This has been added due to iOS limitation where code can't execute after application.run
1 parent 703e0c5 commit fd2c061

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

platform/nativescript/plugins/navigator-plugin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ export default {
1111
return topmost().goBack()
1212
}
1313

14-
Vue.navigateTo = Vue.prototype.$navigateTo = function(component, options) {
14+
Vue.navigateTo = Vue.prototype.$navigateTo = function(
15+
component,
16+
options,
17+
pageCb = () => {}
18+
) {
1519
return new Promise(resolve => {
1620
const placeholder = Vue.$document.createComment('placeholder')
1721

@@ -30,6 +34,8 @@ export default {
3034
const frame = topmost()
3135
const navigate = frame ? frame.navigate : start
3236

37+
pageCb(toPage)
38+
3339
navigate.call(
3440
frame,
3541
Object.assign(

platform/nativescript/plugins/router-plugin.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,16 @@ export default {
107107

108108
const initial = router.getMatchedComponents()[0]
109109

110-
this.$navigateTo(initial, {
111-
context: { router },
112-
clearHistory: true
113-
}).then(page => {
114-
// Todo: this callback never fires on iOS and causes an issue
115-
router.pageStack.push(page)
116-
})
110+
this.$navigateTo(
111+
initial,
112+
{
113+
context: { router },
114+
clearHistory: true
115+
},
116+
page => {
117+
router.pageStack.push(page)
118+
}
119+
)
117120
}
118121
}
119122
})

0 commit comments

Comments
 (0)