Add CoroutineScope to UserRepository
This commit is contained in:
parent
e84dc04418
commit
5cf377598d
1 changed files with 5 additions and 3 deletions
|
@ -6,8 +6,8 @@ import androidx.core.content.edit
|
||||||
import com.wbrawner.nanoflux.network.MinifluxApiService
|
import com.wbrawner.nanoflux.network.MinifluxApiService
|
||||||
import com.wbrawner.nanoflux.network.PREF_KEY_BASE_URL
|
import com.wbrawner.nanoflux.network.PREF_KEY_BASE_URL
|
||||||
import com.wbrawner.nanoflux.storage.dao.UserDao
|
import com.wbrawner.nanoflux.storage.dao.UserDao
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
@ -24,10 +24,12 @@ class UserRepository @Inject constructor(
|
||||||
private val userDao: UserDao,
|
private val userDao: UserDao,
|
||||||
private val logger: Timber.Tree
|
private val logger: Timber.Tree
|
||||||
) {
|
) {
|
||||||
private val _currentUser: MutableSharedFlow<com.wbrawner.nanoflux.storage.model.User> = MutableSharedFlow(replay = 1)
|
private val repositoryScope = CoroutineScope(Dispatchers.IO)
|
||||||
|
private val _currentUser: MutableSharedFlow<com.wbrawner.nanoflux.storage.model.User> =
|
||||||
|
MutableSharedFlow(replay = 1)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
repositoryScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
getCurrentUser()
|
getCurrentUser()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
Loading…
Reference in a new issue