Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
Author: Marcello Galhardo <
Link:
Close eventFlow
when Lifecycle
is DESTROYED
Expand for full commit details
Close `eventFlow` when `Lifecycle` is `DESTROYED`
* `DESTROYED` is a terminal state, and no new emissions will happen after that. Closing the `eventFlow` will signal to consumers that the `eventFlow` has completed its work and they should not wait for new emissions.
* For example: `eventFlow.onCompletion` can be used to clean-up resources used by the flow when the emissions are completed (not only when the flow is cancelled).
RelNote: "`Lifecycle.eventFlow` now correctly complete when `Lifecycle` is `DESTROYED`"
Test: LifecycleEventFlow
Bug: 374043130
Change-Id: I293b274b166de819115e249b624117f0492ed67b
Files:
- M
lifecycle/lifecycle-common/src/commonMain/kotlin/androidx/lifecycle/Lifecycle.kt
- M
lifecycle/lifecycle-runtime-testing/src/commonTest/kotlin/androidx/lifecycle/testing/LifecycleEventFlowTest.kt
Hash: 5aff24c3565cc53389ebed1186a9a3c3e6fb06cc
Date: Thu Oct 17 11:23:02 2024
mg...@google.com <mg...@google.com>
il...@google.com <il...@google.com> #3
This has been fixed internally and will be available in Lifecycle 2.9.0-alpha06.
pr...@google.com <pr...@google.com> #4
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.lifecycle:lifecycle-common:2.9.0-alpha06
androidx.lifecycle:lifecycle-common-iosarm64:2.9.0-alpha06
androidx.lifecycle:lifecycle-common-iossimulatorarm64:2.9.0-alpha06
androidx.lifecycle:lifecycle-common-iosx64:2.9.0-alpha06
androidx.lifecycle:lifecycle-common-jvm:2.9.0-alpha06
androidx.lifecycle:lifecycle-common-linuxarm64:2.9.0-alpha06
androidx.lifecycle:lifecycle-common-linuxx64:2.9.0-alpha06
androidx.lifecycle:lifecycle-common-macosarm64:2.9.0-alpha06
androidx.lifecycle:lifecycle-common-macosx64:2.9.0-alpha06
androidx.lifecycle:lifecycle-runtime-testing:2.9.0-alpha06
androidx.lifecycle:lifecycle-runtime-testing-android:2.9.0-alpha06
androidx.lifecycle:lifecycle-runtime-testing-desktop:2.9.0-alpha06
androidx.lifecycle:lifecycle-runtime-testing-iosarm64:2.9.0-alpha06
androidx.lifecycle:lifecycle-runtime-testing-iossimulatorarm64:2.9.0-alpha06
androidx.lifecycle:lifecycle-runtime-testing-iosx64:2.9.0-alpha06
androidx.lifecycle:lifecycle-runtime-testing-linuxarm64:2.9.0-alpha06
androidx.lifecycle:lifecycle-runtime-testing-linuxx64:2.9.0-alpha06
androidx.lifecycle:lifecycle-runtime-testing-macosarm64:2.9.0-alpha06
androidx.lifecycle:lifecycle-runtime-testing-macosx64:2.9.0-alpha06
Description
Currently, Lifecycle.eventFlow stops sending out new events when the
Lifecycle
reaches theDESTROYED
state. However, theFlow
never completes.Ideally, Lifecycle.eventFlow should complete when the
Lifecycle
isDESTROYED
. This would signal to consumers that they won't receive any new emissions and the flow is terminated.We found this issue while working on b/370577987 , which disallows moving from the
DESTROYED
state to any other state.