Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KoinViewModel is not working as expected #35

Closed
ugurcany opened this issue Jun 14, 2022 · 3 comments
Closed

KoinViewModel is not working as expected #35

ugurcany opened this issue Jun 14, 2022 · 3 comments
Labels
type:issue Something isn't working

Comments

@ugurcany
Copy link
Contributor

I just switched to koin 3.2 & annots 1.0.0 versions. I'm using it in one of my android library modules. the issue is my viewmodel classes which are annotated with @KoinViewModel are defined as "factory" in autogenerated module files:

val com_******_presentation_stock_Stock = module {
   factory(qualifier=null) { com.******.presentation.stock.StockViewModel(get(),get(),get(),get(),get(),get(),get()) } binds(arrayOf(androidx.lifecycle.ViewModel::class,androidx.lifecycle.DefaultLifecycleObserver::class,com.******.presentation.util.ViewStateHolder::class))
}
@arnaudgiuliani
Copy link
Member

yes it has been fixed in 1.0.1

@arnaudgiuliani arnaudgiuliani added the type:issue Something isn't working label Jun 27, 2022
@ugurcany
Copy link
Contributor Author

ugurcany commented Jun 27, 2022

no unfortunately, it's not fixed for delegates. try the following cases:

@KoinViewModel
class OverviewAccountViewModel constructor(
    viewState: OverviewAccountViewState,
    private val getOverviewAccounts: GetOverviewAccounts,
    ......
) : ViewModel(),
    DefaultLifecycleObserver,
    ViewStateHolder<OverviewAccountViewState> by ViewStateHolderImpl(viewState)

outputs the following:

viewModel(qualifier=null) { com.******.presentation.overview.OverviewAccountViewModel(get(),get(),get(),get(),get(),get(),get(),get()) } binds(arrayOf(androidx.lifecycle.ViewModel::class,androidx.lifecycle.DefaultLifecycleObserver::class,com.******.presentation.util.ViewStateHolder::class))

@arnaudgiuliani
Copy link
Member

I don't see the problem here 🤔 It's generated as viewModel else it's another issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:issue Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants