Android kotlin扩展函数 许你一世凡尘 收录于 android2023-04-18 2023-04-18 约 25 字 预计阅读 1 分钟 1 2 3 4 5 6 7 fun <T> ComponentActivity.collectLatestLifecycleFlow(flow: Flow<T>, collect: suspend (T) -> Unit) { lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { flow.collectLatest(collect) } } } 赞赏Please enable JavaScript to view the comments powered by giscus.