kmp-viewmodel-compose
- JetBrains Compose Multiplatform
1.6.0
. - New: Add support for Kotlin/Wasm (
wasmJs
target) 馃帀.
Added kmp-viewmodel-koject
and kmp-viewmodel-koject-compose
artifacts
-
For more information check out the docs/0.x/viewmodel-koject-compose
-
The Koject dependency are used in
kmp-viewmodel-koject-compose
:com.moriatsushi.koject:koject-core:1.3.0
. -
New The
kmp-viewmodel-koject
artifact provides the integration ofkmp-viewmodel
,kmp-viewmodel-compose
andKoject
,
helps us to retrieveViewModel
from the Koject DI container without manually dependency injection.@Provides @Singleton class MyRepository @Provides @ViewModelComponent // <-- To inject SavedStateHandle class MyViewModel( val myRepository: MyRepository, val savedStateHandle: SavedStateHandle, ) : ViewModel() { // ... } @Composable fun MyScreen( viewModel: MyViewModel = kojectKmpViewModel(), ) { // ... }
Example, docs and tests
- Add Compose Multiplatform Koject sample
which sharesViewModel
s and integrates withNavigation
in Compose Multiplatform. It usesKoject
for DI.