Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain old screen #400

Open
grandleaf opened this issue Apr 26, 2024 · 3 comments
Open

Retain old screen #400

grandleaf opened this issue Apr 26, 2024 · 3 comments

Comments

@grandleaf
Copy link

While I appreciate Voyager’s pragmatic interface and flexibility, I’ve encountered an issue: when navigating to a new screen, the old screen gets disposed. Is there an option to instruct Voyager to retain the old screen without destroying it? My concern arises because I’ve integrated a WebView, and disposing and recomposing screens could lead to performance degradation and state loss. Thank you.

@Hightower87
Copy link

I guess, If you want to retain something on your screen which is in the background, use screenModel.
This is compose thing: when a screen is removed from screen, it should be disposed.

@grandleaf
Copy link
Author

@Hightower87, thanks for the suggestion.
Basically I want to put a WebView into the navigation framework. And it is really expensive to recompose a WebView even though its states can somehow be saved by some unofficial approaches.

@duanemalcolm
Copy link

I was after the same behaviour because recomposing my main view was expensive. My work around was to do the following. I'm not sure if this is a good or best approach and would welcome feedback.

var navigator: Navigator? = null

AppTheme() {

    MainScreen(onNavigate = { navigator?.push(it) })

    Navigator(EmptyScreen) { nav ->
        navigator = nav
        SlideTransition(nav)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants