LiveData Reactive Streams and Flowables (MVVM, Retrofit, and RxJava)

In this video I show you how to convert an RxJava Flowable object to LiveData.
By converting a Flowable object to LiveData you can easily integrate the use of RxJava into the Model View View-Model (MVVM) architecture.
➤ Watch the dagger course free:
↻ codingwithmitch.com/courses/d...
➤ Code for this video:
↻ github.com/mitchtabian/Dagger...

Пікірлер: 27

  • @RAHULKANDORIYA
    @RAHULKANDORIYA4 жыл бұрын

    This is the power of internet and of course the people involved!

  • @michaelclara1332
    @michaelclara13324 жыл бұрын

    dude, your videos ARE GREAT, keep it up man. Big fan lol, I make sure to like all your vids I watch!

  • @codingwithmitch

    @codingwithmitch

    4 жыл бұрын

    Thanks I appreciate that

  • @uEffects123
    @uEffects1235 жыл бұрын

    Thanks a billion, that was just the missing piece I needed! I'd just used the regular LiveData without Rx, works just as well and less dependencies :)

  • @preetgandhi1233

    @preetgandhi1233

    4 жыл бұрын

    Hey, I had a doubt how LiveData and Rx are compared, like when to use which?

  • @preetgandhi1233

    @preetgandhi1233

    4 жыл бұрын

    I am currently building an app where i need to fetch the data only no other operations. What should i use LiveData or RxJava?

  • @preetgandhi1233

    @preetgandhi1233

    4 жыл бұрын

    Data is in JSON and very Large.

  • @pradeepkumarreddykondreddy7048

    @pradeepkumarreddykondreddy7048

    3 жыл бұрын

    ​@@preetgandhi1233 We can compare Rx and coroutines, but not LiveData and Rx. LiveData is just a life-cycle aware observable data holder class.

  • @preetgandhi1233

    @preetgandhi1233

    3 жыл бұрын

    @@pradeepkumarreddykondreddy7048 okay thank you

  • @kirill4531
    @kirill45314 жыл бұрын

    Hey Mitch, there is an interesting question in a comment from @Faqrul Ans: why can't we observe the retrofit call and when we get a response - just set value in a regular MuteableLiveData? (which will, in turn, update the activity)? p.s. great video, really want to go through all your tutorials.

  • @Kayander1
    @Kayander14 жыл бұрын

    Great tutorial series! Can you please answer me one question? With retrofit's Call return type there's onError callback (it also appears on RxJava if you use Observables). I used that to detect errors and react to them in some way (Like show error AlertDialog) Using the Flowable-to-LiveData as shown in this video - i can not see any way to detect and react to errors. Can you please clear this out if possible? Thanks a lot!

  • @Kayander1

    @Kayander1

    4 жыл бұрын

    So basically what i am trying to say - how do you detect and determine errors of API calls with the implementation in this video?

  • @gabrieltrifa3434
    @gabrieltrifa34345 жыл бұрын

    Thanks! Very cool what you're doing. Have you consider using data binding for mvvm?

  • @codingwithmitch

    @codingwithmitch

    5 жыл бұрын

    I don't really like data binding. It's ok

  • @FuckTheWholeWord

    @FuckTheWholeWord

    4 жыл бұрын

    @@codingwithmitch Why not?

  • @codingwithmitch

    @codingwithmitch

    4 жыл бұрын

    @@FuckTheWholeWord No reason. I think it's great I just personally don't like to structure things that way.

  • @FuckTheWholeWord

    @FuckTheWholeWord

    4 жыл бұрын

    @@codingwithmitch Then do you prefer ButterKnife?

  • @LalaFafa
    @LalaFafa4 жыл бұрын

    Man this is a Dagger playlist. And in a Dagger playlist you use reactive chains where you could just put a callback on a retrofit async call and put the result in a mutable livedata. Just .... why?

  • @DjangoMx
    @DjangoMx5 жыл бұрын

    i have a question, why use LiveData instead of RxJava in the view? both make the same work

  • @codingwithmitch

    @codingwithmitch

    5 жыл бұрын

    Yeah you could use either. This is the way I approach it: I'm personally more comfortable with LiveData. In this example it literally doesn't matter because it's not a complicated transaction. But when the transactions get more complicated I prefer to do the necessary RX, Then bring everything into the LiveData world simply because I'm more comfortable with it. But it really doesn't matter. You could go all Rx observables. Or you can convert to LiveData like I did. Whatever you like.

  • @kirill4531

    @kirill4531

    4 жыл бұрын

    AFAIK, LiveData is aware of activity/fragment/service lifecycles so you don't need to unsubscribe from it when it's closing or on orientation changes.

  • @faqrulans1321
    @faqrulans13214 жыл бұрын

    First, thank you very much for the explanation sir, but I'm still a little bit confused about LiveDataReactiveStream & MediatorLiveData :'(, why we need these two things here ? Could we just do something like this (?) private MuteableLiveData userAuth = new MuteableLliveData(); public void authenticateWithId(int userId) { authApi.getUser(userId) .subscribeOn() .observeOn() .subscribe(user -> { userAuth.setValue(user) }) }

  • @mahivardhansinghpanwar2127
    @mahivardhansinghpanwar21274 жыл бұрын

    @CodingWithMitch Why did you write the logic for getting data from API in ViewModel. I am your premier customer and in the MVVM course you are getting data from API with help of repository

  • @technicalvenky8778

    @technicalvenky8778

    4 жыл бұрын

    This should be written in the api client -> repository -> viewmodels -> ui

  • @nav213
    @nav2134 жыл бұрын

    cool tutorial however you have mentioned ten times that you have a website and referring newbies to go to your website to check your tutorial...

  • @codingwithmitch

    @codingwithmitch

    4 жыл бұрын

    Man's gotta eat

  • @kirill4531

    @kirill4531

    4 жыл бұрын

    after these tutorials, you can get a job as an Android Developer and earn much more in one hour. Totally worth it.