lifecycleScope.launchWhenResumed
launchWhenResumed
是一个扩展函数,它是LifecycleCoroutineScope
的一部分,并且它是在Android
的Lifecycle
库中引入的。
这个函数的主要目的是在
Lifecycle
的对应组件(通常是Activity
或Fragment
)处于“resumed”状态时启动协程。
public fun LifecycleCoroutineScope.launchWhenResumed(
start: CoroutineStart = CoroutineStart.DEFAULT,
block: suspend CoroutineScope.() -> Unit
): Job
这个函数的参数是:
start
: 协程的启动模式。bl