mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: replace MutableStateFlow direct assignment with update
This commit is contained in:
parent
e272d54833
commit
89b508c0cf
1 changed files with 5 additions and 3 deletions
|
|
@ -10,6 +10,7 @@ import com.geeksville.mesh.CoroutineDispatchers
|
|||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
|
@ -29,9 +30,10 @@ class NetworkRepository @Inject constructor(
|
|||
|
||||
init {
|
||||
processLifecycle.coroutineScope.launch(dispatchers.default) {
|
||||
nsdManagerLazy.get()?.let { manager ->
|
||||
manager.discoverServices(SERVICE_TYPE).collectLatest { serviceList ->
|
||||
_resolvedList.value = serviceList
|
||||
val manager = nsdManagerLazy.get() ?: return@launch
|
||||
manager.discoverServices(SERVICE_TYPE).collectLatest { serviceList ->
|
||||
_resolvedList.update {
|
||||
serviceList
|
||||
.filter { it.serviceName.contains(SERVICE_NAME) }
|
||||
.mapNotNull { manager.resolveService(it) }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue