tylerwilson
04/17/2024, 4:44 PMFor using ViewModels outside of NavHost you need to provide custom store owner via LocalViewModelStoreOwner
I want to use the ViewModel as a base for my own ViewModels to have access to viewModel(Coroutine)Scope. Is this possible with the current alpha04 version, and if so, any examples out there? Thank you!Ivan Matkov
04/17/2024, 4:45 PMIvan Matkov
04/17/2024, 4:46 PMLocalViewModelStoreOwner
that defines lifetime of your ViewModel
s. Currently there is no default one outside of navigationIvan Matkov
04/17/2024, 4:47 PMIvan Matkov
04/17/2024, 4:49 PMLocalViewModelStoreOwner
tylerwilson
04/17/2024, 4:55 PMimplementation(libs.androidx.lifecycle.viewmodel)
to my commonMain, my iOS build fails with:
Showing Recent Messages
No matching variant of org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3 was found. The consumer was configured to find a library for use during 'kotlin-api', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_simulator_arm64', attribute 'org.jetbrains.kotlin.platform.type' with value 'native' but:
Ivan Matkov
04/17/2024, 5:01 PMlibs.androidx.lifecycle.viewmodelIt's a reference to toml. What package and version are you trying to use?
tylerwilson
04/17/2024, 5:04 PMandroidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
where
lifecycle = "2.8.0-alpha04"
tylerwilson
04/17/2024, 5:05 PMIvan Matkov
04/17/2024, 5:06 PM• Thekotlin extensions have now been moved to the base lifecycle module. (Id787b, b/274800183)lifecycle-viewmodel-ktx
• Thekotlin extensions have now been moved to the base lifecycle module. (Ic3686, b/274800183)lifecycle-runtime-ktx
• Thekotlin extensions have now been moved to the base lifecycle module. (I54a3d, b/274800183)lifecycle-livedata-core-ktx
Ivan Matkov
04/17/2024, 5:08 PMorg.jetbrains.androidx.lifecycle:lifecycle-*
. It will redirect to Google's one on supported platforms.Ivan Matkov
04/17/2024, 5:09 PM- Lifecycle libraries. Based on:androidx.lifecycle:lifecycle-*:2.8.0-alpha01
- [Lifecycle 2.8.0-alpha04](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.8.0-alpha04)it's only 2.8.0-alpha01
tylerwilson
04/17/2024, 5:09 PMtylerwilson
04/17/2024, 5:10 PMtylerwilson
04/17/2024, 5:21 PM