Fix using trySendBlocking where trySend must be

This commit is contained in:
Kirill Kamakin
2021-11-23 23:48:53 +03:00
parent db2a0b4a94
commit 57babcbd1f
2 changed files with 2 additions and 4 deletions

View File

@@ -6,7 +6,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.channels.onFailure
import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.withContext
@@ -57,7 +56,7 @@ class AuthStorageImpl @Inject constructor(
else -> return@OnSharedPreferenceChangeListener
}
Timber.d("tokenObservable: New token: $token")
trySendBlocking(token).onFailure { Timber.e(it, "Can't send new token") }
trySend(token).onFailure { Timber.e(it, "Can't send new token") }
}
Timber.v("tokenObservable: registering listener")
send(getToken())

View File

@@ -6,7 +6,6 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.channels.onFailure
import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.collectLatest
@@ -19,7 +18,7 @@ object SwipeRefreshLayoutHelper {
return callbackFlow {
val listener = SwipeRefreshLayout.OnRefreshListener {
Timber.v("Refresh requested")
trySendBlocking(Unit).onFailure { Timber.e(it, "Can't send refresh callback") }
trySend(Unit).onFailure { Timber.e(it, "Can't send refresh callback") }
}
Timber.v("Adding refresh request listener")
setOnRefreshListener(listener)