scope Life
fun LifecycleOwner.scopeLife(lifeEvent: Lifecycle.Event = Lifecycle.Event.ON_DESTROY, dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): AndroidScope
Content copied to clipboard
异步作用域
该作用域生命周期跟随LifecycleOwner
Parameters
lifeEvent
生命周期事件, 默认为Lifecycle.Event.ON_DESTROY下取消协程作用域
dispatcher
调度器, 默认运行在Dispatchers.Main即主线程下
fun Fragment.scopeLife(lifeEvent: Lifecycle.Event = Lifecycle.Event.ON_DESTROY, dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): AndroidScope
Content copied to clipboard
异步作用域
该作用域生命周期跟随Fragment
Parameters
lifeEvent
生命周期事件, 默认为Lifecycle.Event.ON_DESTROY下取消协程作用域
dispatcher
调度器, 默认运行在Dispatchers.Main即主线程下