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

PopBackStack does not have a check for lifecycle state like navigate does #570

Closed
cj1098 opened this issue Jan 25, 2024 · 3 comments
Closed
Labels
enhancement New feature or request feedback needed Extra attention is needed

Comments

@cj1098
Copy link

cj1098 commented Jan 25, 2024

I noticed in navigate you're checking for lifecycle isResumed before navigating. I think popBackStack should also do a check for this as you can have people clicking fast and popping the backstack multiple times unnecessarily.
if this is fixed in a newer version let me know! I'm currently on 1.9.59

@raamcosta raamcosta added the enhancement New feature or request label Jan 26, 2024
@raamcosta raamcosta added the feedback needed Extra attention is needed label Feb 15, 2024
@Rawa
Copy link

Rawa commented Mar 4, 2024

I've been missing this feature as well. It would also come in handy to prevent duplicate back presses. E.g now if we use navigateUp on a back button it might to one too many navigateUp if the user accidentally enters two taps.

@raamcosta
Copy link
Owner

I saw this the other day:

https://x.com/ianhlake/status/1760413602564157779?s=20

Also here:
https://developer.android.com/jetpack/androidx/releases/lifecycle#2.8.0-alpha02

So, I think what's going to happen is that will deprecate the now "onlyIfResumed" parameter in favor of official solution like this. Then you can use that also for navigating back.

@Rawa
Copy link

Rawa commented Mar 12, 2024

Sounds good! Just for anyone looking into this issue later, there is a similar API if you are collecting a flow of side effect from the ViewModel, Flow.flowWithLifecycle .

Reference: https://medium.com/androiddevelopers/a-safer-way-to-collect-flows-from-android-uis-23080b1f8bda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feedback needed Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants