https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
l

Lukasz Kalnik

01/31/2022, 11:02 PM
I use a shared ViewModel in an Android/iOS app. I inject some dependencies there with Koin. However when trying to write data to the
apiConfigRepository
dependency I get the exception `mutation attempt of frozen ApiConfigurationRepositoryImpl@1edb608`:
Copy code
class TVShowsSharedViewModelImpl(
    dispatcher: CoroutineDispatcher = Dispatchers.Main
) : TVShowsSharedViewModel,
    KoinComponent {

    val coroutineScope = CoroutineScope(dispatcher)

    val tmdbApi: TmdbApi by inject()
    val apiConfigRepository: ApiConfigurationRepository by inject()

    init {
        coroutineScope.launch {
            val apiConfig = tmdbApi.getConfiguration()
            with(apiConfigRepository) {
                imageBaseUrl = apiConfig.images.baseUrl
                updateBackdropSizes(apiConfig.images.backdropSizes)
            }
        }
    }
}
l

Luca

02/01/2022, 6:04 AM
l

Lukasz Kalnik

02/01/2022, 8:28 AM
Thank you, I will try that. 🙏
2 Views