# scopeNetLife

fun View.scopeNetLife(dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): ViewCoroutineScope
Content copied to clipboard

视图作用域 会在视图销毁时自动取消作用域

## Parameters

dispatcher

调度器, 默认运行在Dispatchers.Main即主线程下

fun LifecycleOwner.scopeNetLife(lifeEvent: Lifecycle.Event = Lifecycle.Event.ON_DESTROY, dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): NetCoroutineScope
Content copied to clipboard

该函数比scopeNet多了自动取消作用域功能

该作用域生命周期跟随LifecycleOwner. 比如传入Activity会默认在FragmentActivity.onDestroy时取消网络请求.

## Parameters

<receiver>

可传入FragmentActivity/AppCompatActivity, 或者其他的实现了LifecycleOwner的类

lifeEvent

指定LifecycleOwner处于生命周期下取消网络请求/作用域

dispatcher

调度器, 默认运行在Dispatchers.Main即主线程下

fun Fragment.scopeNetLife(lifeEvent: Lifecycle.Event = Lifecycle.Event.ON_DESTROY, dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): NetCoroutineScope
Content copied to clipboard

和scopeNetLife功能相同, 只是接受者为Fragment

## Parameters

lifeEvent

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

dispatcher

调度器, 默认运行在Dispatchers.Main即主线程下