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

proposal: a new flow to dispose things #19

Closed
wants to merge 2 commits into from

Conversation

programadorthi
Copy link
Collaborator

@programadorthi programadorthi commented Oct 16, 2021

Here is try to fix when we are in the first screen and hit back press closing the activity. But the first screen on navigator was not calling disposing function after back press.

So now it will call ScreenModel onDispose or ViewModel onCleared when hit onBackPress in the first screen on Navigator.

This PR is a try to fix #20 and #23 too

@@ -1,14 +1,19 @@
package cafe.adriel.voyager.navigator

import android.app.Activity
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we plan to support KMM soon, depending on Activity will make the task harder. We should find another way to fix this. Perhaps implementing inside AndroidScreen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason to reference Activity here are the two functions created to get current activity and to avoid break working samples. The two functions must be moved our from Navigator file. I'll do that.

@adrielcafe
Copy link
Owner

It doesn't work with nested navigation. Possible solution: before finish the Activity you should verify if navigator.parent is null.

device-2021-10-18-100715.mp4

@programadorthi programadorthi force-pushed the fix/dispose-on-back-press branch 2 times, most recently from ff00b41 to da53436 Compare October 19, 2021 16:39
@programadorthi programadorthi changed the title fix: navigator not disposing after back press on root screen proposal: a new flow to dispose things Oct 21, 2021
@adrielcafe adrielcafe closed this Apr 29, 2022
@adrielcafe adrielcafe deleted the fix/dispose-on-back-press branch April 29, 2022 23:33
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

Successfully merging this pull request may close these issues.

Beta13 hiltviewmodel crash when navigating back to same destination
2 participants