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

Hilt support #11

Closed
kochchy opened this issue Sep 3, 2021 · 5 comments
Closed

Hilt support #11

kochchy opened this issue Sep 3, 2021 · 5 comments

Comments

@kochchy
Copy link

kochchy commented Sep 3, 2021

    val viewModel by hiltViewModel<MyViewModel>() doesnt work inside the @Composable Content function
@programadorthi
Copy link
Collaborator

They are working on it. We'll have news soon.

@adrielcafe
Copy link
Owner

@kochchy hiltViewModel() only works with navigation-compose lib, can you try with viewModel() instead? Make sure to use AndroidScreen instead of Screen.

Please let me know if works.

@kochchy
Copy link
Author

kochchy commented Sep 12, 2021

@adrielcafe with viewModel() java.lang.RuntimeException: Cannot create an instance of class xxx.HomeViewModel

@xinkev
Copy link

xinkev commented Sep 27, 2021

@adrielcafe Will you support hilt injection for ScreenModel? Currently this is the only way I could inject ScreenModels into Screen classes.

@EntryPoint
@InstallIn(ActivityComponent::class)
interface ScreenModelEntryPoint {
    fun home(): HomeModel
    fun login(): LoginViewModel
}

fun entryPoint(
    activity: Activity
): ModelEntryPoint = EntryPointAccessors.fromActivity(activity, ModelEntryPoint::class.java)

@adrielcafe
Copy link
Owner

Hilt integration is available in 1.0.0-beta12. Thanks @programadorthi !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants