Skip to content

Commit

Permalink
fix: generics were erased while retrieving Android ViewModel on Compose.
Browse files Browse the repository at this point in the history
  • Loading branch information
romainbsl committed Jun 26, 2023
1 parent f842685 commit 3d74924
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
repository_id: ${{ steps.create.outputs.repository_id }}
steps:
- id: create
uses: nexus-actions/create-nexus-staging-repo@main
uses: nexus-actions/create-nexus-staging-repo@3e5e7209801629febdcf75541a4898710d28df9a #v1.2
with:
base_url: https://s01.oss.sonatype.org/service/local/
username: ${{ secrets.SONATYPE_USERNAME }}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ plugins {

allprojects {
group = "org.kodein.di"
version = "7.20.1"
version = "7.20.2"
}
2 changes: 1 addition & 1 deletion doc/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ nav:
asciidoc:
attributes:
branch: '7.20'
version: '7.20.1'
version: '7.20.2'
kotlin: '1.8.10'
jdk: '1.8'
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
import org.kodein.di.compose.localDI
import org.kodein.type.erased
import org.kodein.type.generic

/**
* Gets an instance of a [VM] as an android [ViewModel] for the given [tag].
Expand Down Expand Up @@ -93,7 +94,7 @@ public inline fun <reified A : Any, reified VM : ViewModel> rememberViewModel(
factoryProducer = {
KodeinViewModelScopedFactory(
di = di,
argType = erased<A>(),
argType = generic<A>(),
arg = arg,
tag = tag
)
Expand Down Expand Up @@ -127,7 +128,7 @@ public inline fun <reified A : Any, reified VM : ViewModel> viewModel(
remember {
val provider = ViewModelProvider(
viewModelStoreOwner,
KodeinViewModelScopedFactory(di = di, argType = erased<A>(), arg = arg, tag = tag)
KodeinViewModelScopedFactory(di = di, argType = generic<A>(), arg = arg, tag = tag)
)
if (tag == null) {
provider[VM::class.java]
Expand Down

0 comments on commit 3d74924

Please sign in to comment.