In Reactive java we use observable.zip() for combine n numbers of API call or methods result into one .
In LiveData , How we achive this , Any sample code is avilable ?
I don't have code yet but I think you can still achieve the same by using LiveData
Thanks NkoroiEric
I can't find LiveDataReactiveStreams and Publisher class , could you
provide any sample or detailed documentation is helpful for me.
https://developer.android.com/reference/android/arch/lifecycle/LiveDataReactiveStreams.html#fromPublisher(org.reactivestreams.Publisher
On Thu, Jun 1, 2017 at 4:23 PM, NkoroiEric notifications@github.com wrote:
I don't have code yet but I think you can still achieve the same by using
LiveData fromPublisher (Publisher publisher). In this case publisher being
flowable.zip()—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/googlesamples/android-architecture-components/issues/40#issuecomment-305459547,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGcSnY-XM6j0Bjt4SbTDu0SuM7D09jArks5r_pg6gaJpZM4NshUD
.
--
S.Saravanan || +919688851518
Hi!
You have to add
compile "android.arch.lifecycle:reactivestreams:1.0.0-alpha1" // RxJava <-> LiveData
to dependencies
We don't provide these methods because we don't want live data to grow into the complexity of RxJava. That is why we provide the reactivestreams API for RxJava people.
Alternatively, you can implement this yourself using the MediatorLiveData class. It automatically handles passing down lifecycle so that calculations can pause if there are no active observers.
Check the implementation of Transformations class for details.
I have add ,
compile "android.arch.lifecycle:reactivestreams:1.0.0-alpha1"
I got gradle build error :
Error:Failed to resolve: Could not resolve android.arch.lifecycle:reactivestreams:1.0.0-alpha1.
Required by: project :app
Hi man checkout this link for an explanation https://developer.android.com/topic/libraries/architecture/adding-components.html or you can simply add
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
to build.gradle file so as to get the arch dependencies from googles maven repo.
@yigit I agree with you. I think more complex transformations can be added in the Transformations class to make it easier building implementation similar to zip.
@yigit , I was trying your method MediatorLiveData ,it only handle same return type of LiveData not different type LiveData. I tried a lot , but didn't find correct approach to combine the call's using MediatorLiveData and Transfermations.
Here's the Kotlin code I used to implement my zip function, along with useful extension functions: https://gist.github.com/magneticflux-/044c9d7a3cea431aa0e4f4f4950a2898
I had the same needs and at the end I solved with a Kotlin extension that allows me to concatenate livedata results as I did with promises. I created a gist with my solution https://gist.github.com/ch4vi/0f7893bd830f195a99881a30b3cb7640
Create class that contains child and parent room Entity from: https://developer.android.com/reference/androidx/room/Transaction
```
/**
Most helpful comment
We don't provide these methods because we don't want live data to grow into the complexity of RxJava. That is why we provide the reactivestreams API for RxJava people.
Alternatively, you can implement this yourself using the
MediatorLiveDataclass. It automatically handles passing down lifecycle so that calculations can pause if there are no active observers.Check the implementation of
Transformationsclass for details.