https://kotlinlang.org logo
#android
Title
# android
r

RaptorDroid

07/04/2020, 6:33 AM
Copy code
private val results = MediatorLiveData<Result>()
private val dataSource = getData() // returns LiveData<Result>
results.addSource(dataSource){data->
  if(hasNetwork){
    fetchDatafromNetwork(data)
  }else{
    results.value = data
  }
}
Hey guys I am new to RxJava and Android how can i write this in rxJava. what i mean is what can be used inplace of mediatorlivedata or how can this example can be written i nrxjava? Thanks
r

rajesh

07/04/2020, 7:41 AM
Why do you need RxJava if we have Flow and livedata ?
r

RaptorDroid

07/04/2020, 10:24 AM
We already have most of code in rxjava at our company I m just a new intern😅
r

rajesh

07/04/2020, 10:38 AM
When you use LiveData with RxJava you don't need stuff like MediatorLiveDataSwitchMap etc. They are stream control tools and RxJava is better at that by many times.
3 Views