Mikołaj Kąkol
01/25/2021, 4:25 PMclass AppSession internal constructor(globalScope: GlobalScope) {
private val appRepositoryFactory = globalScope.appRepositoryFactory
init {
CoroutineScope(Dispatchers.Default).launch {
withContext(Dispatchers.Default) {
appRepositoryFactory.profilesRepository
}
}
}
this is not
class AppSession internal constructor(globalScope: GlobalScope) {
init {
CoroutineScope(Dispatchers.Default).launch {
withContext(Dispatchers.Default) {
globalScope.appRepositoryFactory.profilesRepository
}
}
}
did someone had something weird? nothing is happening inside this “profilesRepository”. Without coroutines it also works. Error is:
Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen pl.app.di.AppSession@848e28
at 0 MobileBankShared 0x0000000110718fcd kfun:kotlin.Throwable#<init>(kotlin.String?){} + 93 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/Throwable.kt:23:37)
Mikołaj Kąkol
01/25/2021, 4:25 PMclass AppSession internal constructor(globalScope: GlobalScope) {
init {
val appRepositoryFactory = globalScope.appRepositoryFactory
CoroutineScope(Dispatchers.Default).launch {
withContext(Dispatchers.Default) {
appRepositoryFactory.pinRepository
}
}
}
this also works, looks like a bug to meArslan Armanuly
01/25/2021, 6:27 PMappRepositoryFactory
, it frozes and everything is ok. In the second example, you are passing down globalScope
and I guess it can't be frozen because it can contain state.Mikołaj Kąkol
01/25/2021, 6:40 PM