MVVM / MVI Repository Pattern with Hilt

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ก.ค. 2020
  • The best android courses in the world: codingwithmitch.com/
    Watch the HILT course here (FREE): codingwithmitch.com/courses/h...
    A very simple example using MVVM / MVI, Repository Pattern, Hilt dependency injection, Network layer with Retrofit, Caching layer with Room, Coroutines.
    This is a complete example so you can see the big picture when it comes to using Hilt and android architecture.
    Code: github.com/mitchtabian/Dagger...
    Instagram: / codingwithmitch
    Twitter: / mitch_tabian
    .
    .
    #AndroidDev
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @TheAnilmaddala
    @TheAnilmaddala 3 ปีที่แล้ว +104

    This is so useful! and I keep coming back to this. So I created myself a breakdown :)
    0:00 Project Setup
    3:35 Remote Model creation and Retrofit Setup
    12:00 EntityMapper
    16:00 Room Setup and Local cache model creation
    25:00 Dependency Injection - App + Retrofit
    32:05 Dependency Injection - Room
    35:00 DataState
    38:00 MainRepository creation
    43:20 MainViewModel
    46:00 MVI
    51:30 MainActivity

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

    Have been browsing quite a few tutorials on MVI & Clean Architecture and yours is definitely the one that I enjoyed watching. Your way of teaching is really good and I appreciate your hard work behind this. Thank you so much.

  • @lbars
    @lbars 3 ปีที่แล้ว +2

    Yes, exactly what I needed. All architecture concepts at the same video.
    Thank you CodingWithMitch ❤

  • @sheenfabile9460
    @sheenfabile9460 4 ปีที่แล้ว +18

    This is what im looking for! MVI using flow. Will get membership to support your tutorial. Thank you!

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

    Nice tutorial! For anyone wondering, "dao" stands for Data Access Object. So in the context of an database it handles the access to the data.

  • @msontrent9936
    @msontrent9936 2 หลายเดือนก่อน

    Really good tutorial. Far more useful than learning it in a classroom. Thanks for taking the time.

  • @edvardgrei1257
    @edvardgrei1257 3 ปีที่แล้ว +2

    Thank you Mitch. It really opened my eyes. Going to take your paid course for sure. Good Job

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

    PERFECT tutorial! So much knowledge combined. Thank you once again

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

    It is definitely the most useful demo I have ever seen. Thanks Mitch for your contribution, it helps a lot :)

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

    Thank you mitch for wonderful explanation. im working on android almost 2 year with java now i can understand kotline with best approach by watching all your tutorials. I'll suggest your channel and blod and site to colleague.

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

    Awesome job! Thanks for sharing it with all the community

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

    Omg!! Finally.. Was waiting for this tutorial

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

    powerful work! Thanks so much for this video, I will definitely go to your site to see the lessons!

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

    I could literally kiss you for this tutorial 😭😭 its so easy to understand. You just got a new follower.

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

    This is an awesome video Mitch! I wish credit cards were available in my country so I could buy a membership on your site. I’ve been reading the courses’ source code on github and failing to understand some concepts fully, this video helped me immensely!

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

    The most excellent explanation format (a whole hour) - everything from scratch and in order, as in real life, despite the fact that the volume can twitch the eye, but if you do not rush and think about each embedded topic with understanding, it turns out incredibly cool and understandable!!

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

      "despite the fact that the volume can twitch the eye"
      Like the volume of the content or the volume of my audio?

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

      @@codingwithmitch Comparing to other Hilt related videos content))

    •  3 ปีที่แล้ว

      @@bro_chenzox do you still carry that air-compressed gun around?

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

    You're doing a great job with these tutorials.

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

    thank you Matthew(Mitch) , actually english isn't my mother tongue , I'm actually viewing Russian Android developers Channel in youtube , but they're not explaing on begining of project , they're explaining from already done projects and its very heavy to understand if not begin explanation from begining , i'm beginner but I've undertand everything! thank once again. because you've explained from begining in project

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

    This thing is a gold mine! Thanks for the free stuff!

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

    Thanks!!! Everything on one plate. Great Work

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

    thanks Mitch, finally a terrific tutorial!

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

    I enjoyed this implementation example.
    Thanks Mitch

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

    Thank you Mitch,a wonderful video! Your tech is so excellent and your explaination is so consice and awesome!

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

    Awesome.. "YOU NAILED IT"

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

    i really liked it. make more of these kind of videos 1 hour contains the summary of 8 hours course

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

    Big fan of your tutorials man !, I'm even giving a thumbs up without even watching the whole video sometimes

  • @wisnusuryawardhana7891
    @wisnusuryawardhana7891 4 ปีที่แล้ว +8

    THANKS MITCH!!!

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

    wooooh!!
    Hats off to you man[Amazing explanation of android components]... I wish I can hit more likes...

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

    Awesome video !!
    Thank you Mitch you are doing a great work you should be proud of yourself!

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

    Thank you for this tutorial! Intuitive & Very useful !

  • @user-cf5ks8cv8l
    @user-cf5ks8cv8l 3 ปีที่แล้ว

    Thanks for clear and useful example!

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

    Thanks man, such a nice tutorial! Congrats!

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

    The best ever! Thank you sir 🙏🏻

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

    Best tutorial for MVI on youtube, thanks

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

    1000 plus salute man. Your explanation methods are so easy. I don't even know and experience In kotlin still I can understand all the things very clear manners

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

    That's what I was looking for.
    Thank you. ^_^

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

    The best vid to know about modern android development using kotlin,livedata,viewmodel, Hilt and MVi architecture, if the same thing if we want to do with Java and traditional ways..it gonna be 4hrs long r even more...u r awesome Mitch.

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

      and probably 2 hour for debugging things 😂

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

    thanks mitch, very good tutorial

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

    Very helpful video. Thanks!

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

    No words to say....it's awesome tutorial....😍😍😍

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

    Wow that's fantastic video. Thanks Mike.

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

    Awesome video and thank you. Very helpful. Now to figure out how to test that ViewModel and Flow.

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

    Awesome and fast like a bullet :)

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

    Perfect tutorial!

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

    Still The best teacher for android dev i've ever seen hehe

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

    Thanks!! well explained !

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

    great, good job mitch.

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

    Nice tutorial! Thanks! Saludos desde Chile!

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

    Huge Help !! 🙌🏻

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

    This video is what i need. Thanks you

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

    thanks for this amazing video! leared a lot from this video.

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

    Very good quality code!👏👏👏

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

    Am an average developer only. But I have learned a lot by your tutorials. Thanks you a lot Mitch

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

    I love it , well done

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

    Amazing tutorial!!

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

    Great tutorial! Thanks a lot

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

    Awesome tutorial, thanks a lot

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

    Superb explanation keep going. Just at 54:55 you can use progressbar.isVisible = isDisplayed to avoid checking if condition and let that view extension method take care of it. :)

  • @M-MZ
    @M-MZ 3 ปีที่แล้ว

    Great stuff! Thanks

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

    Great Job!

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

    Gettin close to 100k!!!

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

    Hats off to you 🤝

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

    oh my God this is so good.

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

    Awesome!

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

    Thanks , This is Awesome

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

    Thanks for MVI ❤️

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

    Hilt is awsome!

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

    F***ing great!, super helpful !

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

    Awsome 👌 thanks you 🧡

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

    Thank you💯

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

    This is something amazing

  • @AhsanAli-vz6mg
    @AhsanAli-vz6mg 4 ปีที่แล้ว

    Superb

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

    awesome

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

    Thank you

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

    Thank you :D

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

    Hello Man, I have a question. I never used before MVI pattern. I want to ask:
    I have a login screen (a fragment) which uses OAuth2 authentication. I used a viewmodel behind this fragment.
    I created a sealed state class in the ViewModel, in order to manage the state between the fragment and viewmodel. Is correct set the state both from viewmodel and fragment? I mean, there are some states which are managed from the fragment, so I have to set the state from the fragment, and other states which has to be managed from the viewmodel (and through livedate I update/inform the fragment). Is this approach correct? Or the states should be set just from Fragment?
    Then I have some states for example:
    data class ValidLoginStateEvent(val sessionClient: SessionClient) : LoginStateEvent()
    data class NavigateToUserListEvent(val sessionClient: SessionClient) : LoginStateEvent()
    ValidLoginStateEvent is set by Fragment. In the ViewModel I have this:
    when (loginStateEvent) {
    .
    .
    is LoginStateEvent.ValidLoginStateEvent -> {
    bytenerRepository.setSessionClient(loginStateEvent.sessionClient)
    setLoginStateEvent(LoginStateEvent.NavigateToUserListEvent(loginStateEvent.sessionClient))
    }
    is LoginStateEvent.NavigateToUserListEvent -> {
    _state.value = loginStateEvent
    }
    .
    .
    }
    Is this approach correct?

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

    It is supper awesome

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

    This was really useful, thanks.
    P.S: Add chapters to the video please!

  • @pejmanazad5852
    @pejmanazad5852 4 ปีที่แล้ว +10

    My brain is burning. 🔥

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

      why? this is quite easy, and mitch is explaining it very well and simple

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

    Nice tutorial, very neat. I have one question though, if MVI has State mapper in viewModel, does it mean, we can build very large one viewmodel for the whole application?

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

    awsome

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

    Nice video! Keep it up! One question that I have is what is the reason of using dependency injection when Kotlin object can be called from anywhere of the code. For example, the Retrofit module you created in the video can be called directly in the MainRepository class without any DI dependencies. Thanks

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

    Hi , at 44:47 min , you said that "i'm not adding @Inject at the constructor of MainRepository , i will provide this in module" but why cann't you do there only by putting the @Inject annotation , why do we need to create a seprate module for that and while i'm trying to put @Inject annotation in constructor itself , its throwing me error.

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

    Thanks Mitch. That was great. Do you have the same kind of video with a Room database containing 2 tables joined by a SQL inner join (external key in one of the table). If not, take it as a suggestion because all tutorials I have seen so far only use single SQL table example. I wonder how to use SQL INNER JOIN query in room and integrate it in a MVVM project.

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

    Hi Mitch, I really appreciate this session, you explained a lot of concepts in an incredible way. Thanks for that!. I would like to ask you if could you create or design a Base Use Case with this approach. I think use Flow makes the things more efficient but, I tried and I could't create a Base Use Case. Could you please show us a way?

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

    Regarding with creating models, you can find JSON to KT data class Android Studio extension. You just paste there the JSON and data classes are created for you automatically

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

    Can you please explain more about Entity mapper. Like, how to map an entity to a global model if we have multiple hierarchies of objects

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

      Think in a way like moving data from one class to another class, with the same fields available.

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

    Good video, however with new projects Gson isn't the ideal choice, Jake Wharton says to use kotlinx.serialization, Moshi or Jackson. Moshi is basically Gson V3 in all but name.

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

    Hi Mitch, thanks for this example. I have a question, why class DataState and not DataState, what the "out" does?

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

      kotlinlang.org/docs/reference/generics.html

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

    Great Tutorial. What should I do if I need to pass a blog as an argument to the viewmodel in case I want to insert it . How can I incorporate it to the MainStateEvent?

  • @techno-trickster636
    @techno-trickster636 3 ปีที่แล้ว

    ) how hilt know what retrofit instance to provide when we have more than 1 retrofit builder with different base URL

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

    Been waiting for an MVI video! Thanks alot:)
    Quick question
    Is it legit to use firebase as my backend for an app that will have quite a big user base? I read many different opinions, and I am not sure..
    Thanks in advance:)

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

    I have a question, how do we do this if you're using more complex data classes, for example imagin if "Blog" had another class inside, how would we deal with the data relations?

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

    that's good

  • @satnamsingh-qh2si
    @satnamsingh-qh2si 3 ปีที่แล้ว

    🙌🏻

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

    Only "pk" needs the @SerializedName, because it's the only field whose name differs from the JSON response. You also don't need @ColumnInfo unless the field name differs from the column name in your table.

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

    Hello Mitch and thanks for the tutorial. In the RetrofitModule we hard coded the BaseUrl, is it possible to make the BaseUrl dynamic? do we need to create a new RetrofitModule if we have requests with a different BaseUrl? Thanks.

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

    I actually fucking love you

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

    Hey Mitch, first of all, a very helpful tutorial, Just a question, what's the use of caching here? because if the network API fails then we're not retrieving from cache?

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

      Just a simple example. Obviously there should be more detailed error handling

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

      Should we observe to database directly in viewmodel, and also call the API.
      Atleast everytime the loader will not be displayed if data is already in db.
      However caching functionality is not clear to me.

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

    Can you please explain at 49:57 what the .onEach and .launchIn do exactly? Thanks.