AndroidScope

open class AndroidScope(lifecycleOwner: LifecycleOwner?, lifeEvent: Lifecycle.Event, dispatcher: CoroutineDispatcher) : CoroutineScope, Closeable

异步协程作用域

Parameters

lifecycleOwner

生命周期持有者

lifeEvent

生命周期事件, 默认为Lifecycle.Event.ON_DESTROY下取消协程作用域

Constructors

AndroidScope
Link copied to clipboard
fun AndroidScope(lifecycleOwner: LifecycleOwner? = null, lifeEvent: Lifecycle.Event = Lifecycle.Event.ON_DESTROY, dispatcher: CoroutineDispatcher = Dispatchers.Main)
生命周期持有者

Functions

cancel
Link copied to clipboard
open fun cancel(cause: <ERROR CLASS>? = null)
open fun cancel(message: String, cause: Throwable? = null)
catch
Link copied to clipboard
open fun catch(block: AndroidScope.(Throwable) -> Unit = {}): AndroidScope
当作用域内发生异常时回调
close
Link copied to clipboard
open override fun close()
finally
Link copied to clipboard
open fun finally(block: AndroidScope.(Throwable?) -> Unit = {}): AndroidScope
无论正常或者异常结束都将最终执行
handleError
Link copied to clipboard
open fun handleError(e: Throwable)
错误处理
launch
Link copied to clipboard
open fun launch(block: suspend CoroutineScope.() -> Unit): AndroidScope

Properties

coroutineContext
Link copied to clipboard
open override val coroutineContext: CoroutineContext
dispatcher
Link copied to clipboard
val dispatcher: CoroutineDispatcher
scopeGroup
Link copied to clipboard
val scopeGroup: <ERROR CLASS>

Inheritors

NetCoroutineScope
Link copied to clipboard