Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 317e3271 authored by Chaohui Wang's avatar Chaohui Wang
Browse files

Improve the document of collectLatestWithLifecycle

Bug: 329584989
Flag: EXEMPT document only
Test: N/A
Change-Id: I1af1c11f51b8300375e46f93fdbc6afa56d0c2ad
parent 0d464ac3
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -54,9 +54,11 @@ inline fun <T> Flow<List<T>>.filterItem(crossinline predicate: (T) -> Boolean):
fun <T1, T2> Flow<T1>.waitFirst(otherFlow: Flow<T2>): Flow<T1> =
    combine(otherFlow.take(1)) { value, _ -> value }


/**
 * Collects the latest value of given flow with a provided action with [LifecycleOwner].
 *
 * This helper function is designed to work with non Compose code. For Compose, please collect the
 * flow in a `LaunchedEffect` instead to ensure disposable and re-enter safe.
 */
fun <T> Flow<T>.collectLatestWithLifecycle(
    lifecycleOwner: LifecycleOwner,