嗨,我只是想知道在 SharedFlow 中獲取查詢結果時哪個代碼片段更適合范圍
val categories = categoryRepository.getAll().shareIn(
scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5000),
replay = 0
)
val categories = categoryRepository.getAll().shareIn(
scope = CoroutineScope(Dispatchers.IO),
started = SharingStarted.WhileSubscribed(5000),
replay = 0
)
uj5u.com熱心網友回復:
這個更好
val categories = categoryRepository.getAll().shareIn(
scope = CoroutineScope(Dispatchers.IO),
started = SharingStarted.WhileSubscribed(5000),
replay = 0
)
正如viewModelScope必然Dispatchers.Main.immediate
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/454176.html
上一篇:使用mapshaper簡化GeoJsonFeatureCollection會導致問題
下一篇:使用過濾器創建子串列不起作用
