Комментарии:
Thank you philip, the annotation @Named one helps me to deal with the problem with multiple BASE URL, Thankkk uuuu
ОтветитьWhat if im depended on a runtime thing ?
E.g
On my app I have a number picker. With 1 and 2. If user select 1 I want to Inject X thing, if user select 2 I want to inject Y thing.
This X and Y are the same type. Type of Z. So in my viewModel (or whenever this will be used) I want only to `@Inject lateinit var test: Z`.
One more point about Dagger Hilt is that you are not able to configure it for the library project as the entry point for it always has to be the Application which is absent in the library.
ОтветитьExcellent 👍
ОтветитьThis video needs to be updated because the gradle dependencies that are mentioned are not correct at this time and the dependency for "hilt-lifecycle-viewmodel" isn't needed in the newer versions of the library (if it's added to your project, there will be runtime errors).
Ответитьthumbnail 😂😅🤣😂😂
ОтветитьHey there. I get an error when trying to run the last thing you explained with the view model. When I replace the @InstallIn(ActivityComponent..) and @ActivityScoped annotations with @IntallIn(SingletoneComponent..) and @Singleton it works. I think it's because the MainModule which provides dependencies at an activity layer relies on the AppModule which provides dependencies at application level (because it's annotated as a singleton). Am I missing something?
Ответитьhow i can create a singleton viewmodel sheard between 2 screens
Ответитьすごく参考になりました。ありがとうございます!
ОтветитьSound's like you're saying "knasp" and "knas" instead of "class"
Ответитьhow can u buy video course "
ОтветитьThanks for making such clear and elaborative videos. Best
ОтветитьIs @Singleton is same as 'object' keyword in Kotlin?
ОтветитьI finally understand what is digger hilt after days of research...
ОтветитьApplicationComponent is now replaced with SingletonComponent in the new version of hilt.
ОтветитьIt would be awesome to explain and show things about scoping, regardless this is a good video coming from plain Dagger 2
ОтветитьWhat if the variable string2 was created in the activity in a scenario like from IntentExtras and we need to pass it to the ViewModel without using a ViewModel factory
ОтветитьThanks for such a wonderful explanation
I appreciate your efforts
i come back again!! thanks phillipp
😀Actually , you give me a lot help in Android dev!!
Watching your videos feels like cheating :). Every time I struggle with something I always watch one of your relevant videos, and voila. Thanks a million times and more man...
Ответитьi had error when run this code, "unrecognized attribute name module (class com.sun.tools.javac.util.sharednametable$nameimpl)". someone can help?
ОтветитьThank you great explanation 🙏
Ответитьfor a strange reason I used hilt version 2.35 and it didn't work for me, then I used hilt version 2.40.5 and it worked, maybe someone has experienced the same thing
Ответить@ViewModelInject annotation doesn't exist anymore. To inject dependencies in ViewModel we need to use the same @Inject constructor() like in activities, but also we have to annotate our ViewModel as @HiltViewModel.
ОтветитьI am getting this error
Execution failed for task ':app:kaptDebugKotlin'.
How do I fix it?
Any chance you can update this? Your tutorials are great, but there have been a number of changes and Google is horrible when it comes to teaching anything
ОтветитьThanks for your amazing tutorials ❤
ОтветитьThank you so much for this amazing video.
ОтветитьYou are the best !!!
Ответитьthe TestViewModel example does not work with lastest hill versions.
Ответитьhey man, as always thanks for the great video, but i want to ask why don't u use koin for dependency injection? it is much much more simpler to use in my opinion
ОтветитьYou should be awarded
ОтветитьThank you for explaining hilt in details !!!!
ОтветитьWish I can like this tutorial more than one time! You saved my days, thank you!
ОтветитьI've always thought CodingInFlow and CodingWithMitch's tutorials were good, but yours are better.
Ответитьyou are a good teacher i love your way of teaching please keep it up and upload more tutorials.
ОтветитьOh man, it exactly that I was looking for! Thank you so much!
ОтветитьWhen I try to inject to the activity the viewmodel like this fails to compile for this reason:
Classifier 'RoutesListViewModel' does not have a companion object, and thus must be initialized here
Anyone knows how to solve this?
For those having trouble with ViewModel log cat:
@Module
@InstallIn(ActivityRetainedComponent ::class)
object MainModule {
// This will only live in main activity
// Cannot have @singleton that only lives as long as our activity
// Instead of @Singleton, we use activity scoped
@ActivityRetainedScoped
@Provides
@Named("String2")
// if we need to access context, say strings file, how?
// We used context as a parameter!!
// dagger hilt will also figure out which testString1 we will inject!!
fun provideTestString2(@ApplicationContext context: Context,
@Named("String1") testString1: String) =
"${context.getString(R.string.string_to_inject)} - $testString1"
}
Couldn't be better explained. Thanks!
Ответитьnice vid. unfortunately hilt doesnt support DI in kotlin object . or do you know how to?
ОтветитьYou should use the SingletonComponent, as ApplicationComponent doesn't exist in the new Dagger anymore.
Ответитьthanks a lot, but in hilt module ApplicationComponent replaced with SingletonComponent
Ответитьnice
Ответить