Hilt ViewModels and Dependency Injection

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ม.ค. 2025

ความคิดเห็น • 114

  • @NMNaufaldo
    @NMNaufaldo 3 ปีที่แล้ว +26

    2:36 It seem in the new version of Hilt, we don't need `hilt-lifecycle-viewmodel` dependency

  • @burakkarabekir2863
    @burakkarabekir2863 3 ปีที่แล้ว +18

    Deprecate @ViewModelInject. Equivalent functionality is now offered by @HiltViewModel, which is now part of the core Hilt Android APIs.

  • @tarikhusin1767
    @tarikhusin1767 3 ปีที่แล้ว +20

    newer version of hilt use @HiltViewModel before the class and @Inject before the constructor
    @HiltViewModel
    class RecipeListViewModel @Inject constructor() : ViewModel() {
    }

    • @typingcat
      @typingcat 3 ปีที่แล้ว +1

      Also, AppModule's ApplicationComponent:class -> SingletonComponent:class

  • @jswaby
    @jswaby 4 ปีที่แล้ว +5

    Appreciate the hilt info. Here's some complimentary engagement!

  • @amleshkumar4917
    @amleshkumar4917 2 ปีที่แล้ว +1

    Hey Mitch, your each and every video is very informative and your explanation is too good

  • @brijeshmorya9737
    @brijeshmorya9737 ปีที่แล้ว

    your setup is really nice.

  • @mohsenmdb9786
    @mohsenmdb9786 2 ปีที่แล้ว

    Hey Mitch you're so powerful in teaching

  • @felipefranco7444
    @felipefranco7444 4 ปีที่แล้ว +2

    Mitch thank you for your mention bro thats very cool!!!!!! ENGAGEMENT!

  • @staceyrichards8656
    @staceyrichards8656 3 ปีที่แล้ว

    Many thanks Mitch. Very informative as usual. It makes things so much clearer when you show simple examples for each use case.

  • @oscarivan7697
    @oscarivan7697 3 ปีที่แล้ว

    I'm just in this part of the course and now i want the Kotlin mobile multiplatform course. btw take your engagement

  • @ashurajput11
    @ashurajput11 3 ปีที่แล้ว

    Yes definitely wanna appreciate Google for hilt but equally wanna appreciate your efforts as well... Thanks ;)

  • @muhammedshahin6299
    @muhammedshahin6299 2 ปีที่แล้ว

    Thank you so much for the amazing videos, mitch.

  • @mikemikee7797
    @mikemikee7797 4 ปีที่แล้ว +9

    private val engagement : Engagement by Subscribers()

  • @SatyamRaikwar262238
    @SatyamRaikwar262238 3 ปีที่แล้ว

    Hi Engagements here!! :))
    Thanks

  • @디구산
    @디구산 3 ปีที่แล้ว

    Thank you Mitch ... from s.korea

  • @MuhammadNaveed2016
    @MuhammadNaveed2016 4 ปีที่แล้ว +1

    Universal Android Boss

  • @vichuz100
    @vichuz100 2 ปีที่แล้ว

    Thanks Mitch, you saved my day 😍

  • @mishaeliseev
    @mishaeliseev 4 ปีที่แล้ว

    Привет, Митч ! Отличное видео ! Кажется я понял, как использовать Hilt )

  • @jude-l3f
    @jude-l3f 4 ปีที่แล้ว +1

    Great stuff 👍, looking forward to more hilt

  • @KIRILLINGUSS21
    @KIRILLINGUSS21 4 ปีที่แล้ว +1

    Thank you, Mitch

  • @davidscammell9823
    @davidscammell9823 4 ปีที่แล้ว +1

    Nice one Mitch!

  • @eiphyuphwe9269
    @eiphyuphwe9269 3 ปีที่แล้ว

    love it Mitch! Engagement pls

  • @MedAmineSouaiaia88
    @MedAmineSouaiaia88 4 ปีที่แล้ว +2

    Always so clear! thank you

  • @YouGuto
    @YouGuto 4 ปีที่แล้ว

    Engagement! Mitch try to use scrcpy instead of visor. You gonna love it!

    • @codingwithmitch
      @codingwithmitch  4 ปีที่แล้ว +1

      I already paid for it so gotta get my monies worth 😂

  • @berkaykirecci1169
    @berkaykirecci1169 4 ปีที่แล้ว +1

    Good job! Do you consider to make video about "Error handling with coroutines and retrofit" ? Since there are a a lot of workarounds, i dont know how to use them efficiently.

    • @codingwithmitch
      @codingwithmitch  4 ปีที่แล้ว +2

      Yeah that'll be in the next course. Generally I use something like this to execute the api/cache calls and handle errors github.com/mitchtabian/Clean-Notes/blob/master/app/src/main/java/com/codingwithmitch/cleannotes/business/data/util/RepositoryExtensions.kt

  • @gunjotsingh3638
    @gunjotsingh3638 3 ปีที่แล้ว

    Loved it 🙌🏻

  • @faustofl
    @faustofl 4 ปีที่แล้ว +1

    Hi Mitch!
    Have you ever tried scrcpy instead of Vysor?
    Take a look!
    Tks for the coding class. I`m learning a lot here in Bazil.
    Best regards

  • @blackballization
    @blackballization 2 ปีที่แล้ว

    Thank you very helpful tutorial

  • @nayeramohamed436
    @nayeramohamed436 3 ปีที่แล้ว

    What if you want to share view models using navigation scope or parent fragment scope only? how would you do that using this approach?

  • @moussawade5957
    @moussawade5957 4 ปีที่แล้ว +1

    Many thanks to you Mitch 👍

  • @deepakgahlot6879
    @deepakgahlot6879 4 ปีที่แล้ว +1

    great work!!!!!! thank you for all your effort

  • @leolizanon2503
    @leolizanon2503 2 ปีที่แล้ว

    Thanks so much, this saved my code

  • @watziznaim
    @watziznaim 11 หลายเดือนก่อน

    Great stuff 👍

  • @amansahai7502
    @amansahai7502 3 ปีที่แล้ว

    Simplified learning experience, Here's some engagement

  • @genesiscatano
    @genesiscatano 3 ปีที่แล้ว

    That was great!! What about if you already have dagger? how can I implement Hilt while still have dagger. I don't want to do the migration just yet.

  • @vaibhavjaiswal5911
    @vaibhavjaiswal5911 4 ปีที่แล้ว

    What if there are two different string dependency in the hilt module and we want both of them , then how would dagger inject both ???

  • @yogenp5763
    @yogenp5763 3 ปีที่แล้ว

    Thanks Mitch for the video

  • @martindelbel
    @martindelbel 4 ปีที่แล้ว +2

    boom now I know hilt

  • @vengateshm2122
    @vengateshm2122 4 ปีที่แล้ว

    What if we want to inject something inside a Utility class. Can we still use @AndroidEntryPoint? In koin di framework we use KoinComponent everywhere. Please answer.

  • @emil_fa
    @emil_fa 4 ปีที่แล้ว +1

    Hey Mitch, I was wondering if it might be error prone to use "by activityViewModels" when using Navigation Component with the Single Activity Pattern, as the View Model instance will then effectively be exposed to the entire scope of the app? I've heard of a way to scope View Models to individual navigation graphs with Hilt (haven't tried it yet), but do you know of a way where you can share a View Model instance between only a defined subset of Fragments? Thanks for the course, helps out a lot!

    • @codingwithmitch
      @codingwithmitch  4 ปีที่แล้ว +1

      That is a very good question. I also have not tried the method of scoping to a graph. I don't know the answer to your question.

    • @i11uminati87
      @i11uminati87 3 ปีที่แล้ว

      @@codingwithmitch I would love to see an answer to this question. Do you have any updates since then?

  • @sanushradalage4091
    @sanushradalage4091 4 ปีที่แล้ว

    Hi when I created fragments its ask to implement these two methods inside fragment class. I havent any idea about this
    override fun prepareCall(
    contract: ActivityResultContract,
    callback: ActivityResultCallback
    ): ActivityResultLauncher {
    TODO("Not yet implemented")
    }
    override fun prepareCall(
    contract: ActivityResultContract,
    registry: ActivityResultRegistry,
    callback: ActivityResultCallback
    ): ActivityResultLauncher {
    TODO("Not yet implemented")
    }

  • @hellespont5072
    @hellespont5072 3 ปีที่แล้ว

    Loving these lessons 👌

  • @tomandjerryofficial2030
    @tomandjerryofficial2030 4 ปีที่แล้ว

    Thanks Mitch. My ViewModel was throwing an exception since I hadn't put
    (kapt "androidx.hilt:hilt-compiler:1.0.0-alpha02") in my app's build.gradle.
    Quick question, is field injection possible inside a ViewModel using Hilt?

    • @codingwithmitch
      @codingwithmitch  4 ปีที่แล้ว

      I don't think so. but there's no reason to anyway. Hilt does all the heavy lifting so you can just magically pass anything as a constructor arg.

  • @vineedcool
    @vineedcool 4 ปีที่แล้ว

    You should try scrcpy tool for screen mirroring,it's opensource and no need to install any app in your mobile so basically more secure

    • @codingwithmitch
      @codingwithmitch  4 ปีที่แล้ว

      already paid for vysor so trying to get my monies worth

  • @naimishmodi4193
    @naimishmodi4193 4 ปีที่แล้ว

    Hello
    I don't understand this
    by viewModel()
    It means we don't have to initialise like this
    ViewModelProvider(this).get(MyViewModel::class.java) ??

  • @Zaki-Was-Here
    @Zaki-Was-Here 3 ปีที่แล้ว

    What about sharing viewmodel between activities is it the same way ?

  • @hnim2292
    @hnim2292 4 ปีที่แล้ว +1

    remember bad old days view model injection with Dagger

  • @be_like__prateek
    @be_like__prateek 3 ปีที่แล้ว

    Great content 🔥

  • @subhendubanerjee8600
    @subhendubanerjee8600 3 ปีที่แล้ว

    Hi Mitch, your videos are really very useful , would you pls create a multi module project using Hilt .. eagerly waiting for this video .. thanks in advance 🙂

  • @Rafael-hk9pg
    @Rafael-hk9pg 3 ปีที่แล้ว

    I get an error on your website when trying to register. I would like to follow the Hilt course!

  • @devguru8443
    @devguru8443 3 ปีที่แล้ว

    Great work. Also, Can you cover inject viewModels with Fragment/Bundle arguments?

  • @jvoyager1
    @jvoyager1 4 ปีที่แล้ว

    thnx for the tutorial, appreciate it

  • @wajdidaghlas3178
    @wajdidaghlas3178 4 ปีที่แล้ว +1

    Good master

  • @leetcodeforbeginners
    @leetcodeforbeginners 4 ปีที่แล้ว +1

    Ur the guy

  • @tonnie7079
    @tonnie7079 3 ปีที่แล้ว

    great stuff

  • @sirlordpouya
    @sirlordpouya 3 ปีที่แล้ว

    Hi Mitch. Is there any convenient solution to pass parameters to ViewModel in runtime by Hilt?

  • @kamilboryczka7117
    @kamilboryczka7117 4 ปีที่แล้ว

    Can you record a tutorial on how to prepopulate Room db using Hilt?

  • @arulwastaken
    @arulwastaken 4 ปีที่แล้ว

    cool as ever

  • @khiariyoussef6674
    @khiariyoussef6674 4 ปีที่แล้ว

    Why can't i annotate my activities&fragments with AndroidEntryPoint when the classes are abstract ? like an abstract baseActivity !! is there anyway to handle this ?

    • @codingwithmitch
      @codingwithmitch  4 ปีที่แล้ว +1

      Actually I haven't tried. Didn't know that

  • @vanosuperhero
    @vanosuperhero 3 ปีที่แล้ว

    Thanks!

  • @samha1513
    @samha1513 3 ปีที่แล้ว +1

    Hilt wont import the ApplicationComponent class

    • @codingwithmitch
      @codingwithmitch  3 ปีที่แล้ว +1

      It's SingletonComponent now SAM YOU SHOULD KNOW THAT

    • @samha1513
      @samha1513 3 ปีที่แล้ว +1

      @@codingwithmitch lol i figured. Damn I'm way behind 😂

    • @samha1513
      @samha1513 3 ปีที่แล้ว +1

      @@codingwithmitch but it did actually worked yesterday and this morning it just wouldn't work. i had to open the documents and it was right there 🤣

  • @kshitijpatil2019
    @kshitijpatil2019 4 ปีที่แล้ว +1

    I find it difficult to ENGAGE with Android Studio when Dagger/Hilt is being used in a project. Looks like Modern Android Development with Hilt involed needs to have separate system requirements Column on Android Studio page 😂

    • @codingwithmitch
      @codingwithmitch  4 ปีที่แล้ว

      Lol just watch my hilt course it's free

    • @kshitijpatil2019
      @kshitijpatil2019 4 ปีที่แล้ว

      Yeah I've already checked that and have tried to use Hilt in project. Hilt makes DI incredibly easy but since it under the hood uses Dagger only which heavily adds to your build time, I decided not to use Hilt unless I get an access to high specs machine. I feel atleast 16GB of RAM with SSD is must for using these tools smoothly.

  • @saranshsinghal132
    @saranshsinghal132 ปีที่แล้ว

    thanks

  • @terencejumba1939
    @terencejumba1939 3 ปีที่แล้ว

    nice one

  • @avinashdas1013
    @avinashdas1013 4 ปีที่แล้ว

    Mitch please help. I am stuck with the DAO video Data Entity thing. Please suggest where to read about it. You are moving too fast.

    • @codingwithmitch
      @codingwithmitch  4 ปีที่แล้ว

      We don't even have a Dao

    • @avinashdas1013
      @avinashdas1013 4 ปีที่แล้ว

      @@codingwithmitch th-cam.com/video/rTWCxow5IJQ/w-d-xo.html Forgive me, its this one.

    • @codingwithmitch
      @codingwithmitch  4 ปีที่แล้ว

      @@avinashdas1013 That is a DTO not a DAO. Dao is used with room persistence library.

    • @avinashdas1013
      @avinashdas1013 4 ปีที่แล้ว +1

      @@codingwithmitch Thank you Mitch. I have never heard these terminology before. Sure I have to do alot of catch-up before I can continue with this series. 🙏🙏

  • @mandarliev
    @mandarliev 3 ปีที่แล้ว

    Does someone receive the following error when starting the application: Error inflating class androidx.fragment.app.FragmentContainerView

  • @datadata4039
    @datadata4039 3 ปีที่แล้ว

    Epic!

  • @johnybaby9574
    @johnybaby9574 4 ปีที่แล้ว

    I like this!

  • @MrMayur6028
    @MrMayur6028 3 ปีที่แล้ว

    Thanks Mitch

  • @freesk13r
    @freesk13r 3 ปีที่แล้ว

    I didn’t know Alexender Volkanovski knew so much about Android dev..

  • @juniorlapunete4660
    @juniorlapunete4660 4 ปีที่แล้ว

    Hi Mitch, please can you make more videos about CRUD MVI using Kotlin?

    • @codingwithmitch
      @codingwithmitch  4 ปีที่แล้ว

      Entire course right here my friend codingwithmitch.com/courses/android-clean-architecture/

  • @LEGENDMORTAL
    @LEGENDMORTAL 3 ปีที่แล้ว

    awesome

  • @anuradhaamarasinghe9649
    @anuradhaamarasinghe9649 3 ปีที่แล้ว

    Engagementooooo :)

  • @slaviccat5375
    @slaviccat5375 3 ปีที่แล้ว

    Why don't you switch to dark theme ? I think that would make viewers happy, and your eyes :D

  • @iam-learning6374
    @iam-learning6374 4 ปีที่แล้ว

    How we can Create BaseFragment to instantiate ViewModel- val viewModel: EngagementViewModel by viewmodels() - thanks! -

    • @codingwithmitch
      @codingwithmitch  4 ปีที่แล้ว

      I don't think you need to do anything special. Try instantiating it in the abstract class I think it will work fine. I could be wrong tho I'm not at my computer

  • @applombaa6278
    @applombaa6278 3 ปีที่แล้ว

    love his

  • @prashantsurti5788
    @prashantsurti5788 4 ปีที่แล้ว +2

    engagement

  • @DS-bz4mz
    @DS-bz4mz 2 ปีที่แล้ว

    Engagementtttttttt

  • @vedx
    @vedx 4 ปีที่แล้ว +3

    You always forget to add card. Btw engagement is new normal 😂.

  • @JATHubb
    @JATHubb 4 ปีที่แล้ว +1

    Mitch

  • @mandarliev
    @mandarliev 3 ปีที่แล้ว

    I think the ViewModelnject is deprecated now and the right one is ViewModelScoped :)

    • @diegoramms
      @diegoramms 3 ปีที่แล้ว +1

      use HiltViewModel

  • @muhammadshayankhan3066
    @muhammadshayankhan3066 4 ปีที่แล้ว +1

    Engagement

  • @farjadilyas9549
    @farjadilyas9549 3 ปีที่แล้ว

    some engagement 4 u

  • @johnchance5446
    @johnchance5446 3 ปีที่แล้ว

    You can rest assured that I will never watch anything else than a free course.

  • @alishechka29
    @alishechka29 4 ปีที่แล้ว

    bump

  • @alexanderk9767
    @alexanderk9767 3 ปีที่แล้ว

    Like for shared VM trick

  • @michaeli5113
    @michaeli5113 3 ปีที่แล้ว

    you obviously know the content and are very excellent with android, but its difficult for me to follow because you talk way too fast and just "code". more of "how its done kinda guy," not "what it is and why its doing this". because of that i dont understand the code and your speech speeed doesnt help. kudos all the same @least for those who seem to understand you

  • @ChrisAthanas
    @ChrisAthanas 4 ปีที่แล้ว +1

    Engagement