nativescript-vue / nativescript-vue-navigator

A simple router for NativeScript-Vue, built on top of $navigateTo to simplify routing from within components
MIT License
98 stars 10 forks source link

keep-alive is not supported? #26

Closed ukik closed 4 years ago

ukik commented 4 years ago

I use below but nothing effect?

<keep-alive>
        <Navigator :defaultRoute="!isLoggedIn ? '/home' : '/view-habit-organisasi'"/>
</keep-alive>
rigor789 commented 4 years ago

No, keep-alive does not work with frames (thus navigator).

What would be the expected behavior? Keeping previous routes alive? If so, just utilize the backstack, since that's what it's for.

jadedigital commented 4 years ago

Lets say you have bottom navigation, each displaying a different route. Each route needs to fetch data from an api before it is displayed. Ideally this data fetch would only happen once, then each route can be kept alive so that navigating back and forth between your bottom tabs is fast.

At the moment I'm using the BottomNavigation component, which does seem to keep all tabs alive. But it also seems to load all the routes upon initial render, which means all data is being fetched for each route when the app first loads and I think it's causing the initial render to take a little longer.

rigor789 commented 4 years ago

@jadedigital it's probably a good idea to delegate the fetching to a central place (like vuex) where you can cache the retrieved data.

Due to the infinite number of possibilities with view hierarchies - it's not feasible to support KeepAlive with Frames (and thus the Navigator) as they are managed by a native backstack that we don't have much control of.