Skip to content

Most visited

Recently visited

navigation

LiveDataReactiveStreams

public final class LiveDataReactiveStreams
extends Object

java.lang.Object
   ↳ android.arch.lifecycle.LiveDataReactiveStreams


Adapts LiveData input and output to the ReactiveStreams spec.

Summary

Public methods

static <T> LiveData<T> fromPublisher(Publisher<T> publisher)

Creates an Observable LiveData stream from a ReactiveStreams publisher.

static <T> Publisher<T> toPublisher(LifecycleOwner lifecycle, LiveData<T> liveData)

Adapts the given LiveData stream to a ReactiveStreams Publisher.

Inherited methods

From class java.lang.Object

Public methods

fromPublisher

LiveData<T> fromPublisher (Publisher<T> publisher)

Creates an Observable LiveData stream from a ReactiveStreams publisher.

Parameters
publisher Publisher

Returns
LiveData<T>

toPublisher

Publisher<T> toPublisher (LifecycleOwner lifecycle, 
                LiveData<T> liveData)

Adapts the given LiveData stream to a ReactiveStreams Publisher.

By using a good publisher implementation such as RxJava 2.x Flowables, most consumers will be able to let the library deal with backpressure using operators and not need to worry about ever manually calling request(long).

On subscription to the publisher, the observer will attach to the given LiveData. Once {@link Subscription#request) is called on the subscription object, an observer will be connected to the data stream. Calling request(Long.MAX_VALUE) is equivalent to creating an unbounded stream with no backpressure. If request with a finite count reaches 0, the observer will buffer the latest item and emit it to the subscriber when data is again requested. Any other items emitted during the time there was no backpressure requested will be dropped.

Parameters
lifecycle LifecycleOwner

liveData LiveData

Returns
Publisher<T>

This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.