# LiveDataReactiveStreams

added in[version 1.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact android.arch.lifecycle:reactivestreams:1.1.1  
Summary:[Methods](https://developer.android.com/reference/android/arch/lifecycle/LiveDataReactiveStreams#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/arch/lifecycle/LiveDataReactiveStreams#inhmethods)  

# LiveDataReactiveStreams

| The`android.arch`Architecture Components packages are no longer maintained. They have been superseded by the corresponding[androidx.\*](https://developer.android.com/jetpack/androidx/migrate)packages. See[androidx.lifecycle.LiveDataReactiveStreams](https://developer.android.com/reference/androidx/lifecycle/LiveDataReactiveStreams)instead.

`
public

final

class
LiveDataReactiveStreams
`  
`

extends Object


``


`

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

<br />

*** ** * ** ***

Adapts[LiveData](https://developer.android.com/reference/android/arch/lifecycle/LiveData)input and output to the ReactiveStreams spec.

## Summary

|                                                                                                                                                                                                                                                                                                                                                              ### Public methods                                                                                                                                                                                                                                                                                                                                                              ||
|--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static <T> `[LiveData](https://developer.android.com/reference/android/arch/lifecycle/LiveData)`<T>` | ` `[fromPublisher](https://developer.android.com/reference/android/arch/lifecycle/LiveDataReactiveStreams#fromPublisher(org.reactivestreams.Publisher<T>))`(Publisher<T> publisher) ` Creates an Observable[LiveData](https://developer.android.com/reference/android/arch/lifecycle/LiveData)stream from a ReactiveStreams publisher.                                                                                                                                                                                                                                                                                               |
| ` static <T> Publisher<T>`                                                                             | ` `[toPublisher](https://developer.android.com/reference/android/arch/lifecycle/LiveDataReactiveStreams#toPublisher(android.arch.lifecycle.LifecycleOwner, android.arch.lifecycle.LiveData<T>))`(`[LifecycleOwner](https://developer.android.com/reference/android/arch/lifecycle/LifecycleOwner)` lifecycle, `[LiveData](https://developer.android.com/reference/android/arch/lifecycle/LiveData)`<T> liveData) ` Adapts the given[LiveData](https://developer.android.com/reference/android/arch/lifecycle/LiveData)stream to a ReactiveStreams[Publisher](https://developer.android.com/reference/org/reactivestreams/Publisher). |

| ### Inherited methods |
|-----------------------|---|
| From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public methods

### fromPublisher

added in[version 1.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Creates an Observable[LiveData](https://developer.android.com/reference/android/arch/lifecycle/LiveData)stream from a ReactiveStreams publisher.

When the LiveData becomes active, it subscribes to the emissions from the Publisher.

When the LiveData becomes inactive, the subscription is cleared. LiveData holds the last value emitted by the Publisher when the LiveData was active.

Therefore, in the case of a hot RxJava Observable, when a new LiveData[Observer](https://developer.android.com/reference/android/arch/lifecycle/Observer)is added, it will automatically notify with the last value held in LiveData, which might not be the last value emitted by the Publisher.

Note that LiveData does NOT handle errors and it expects that errors are treated as states in the data that's held. In case of an error being emitted by the publisher, an error will be propagated to the main thread and the app will crash.

<br />

|           Parameters            ||
|-------------|--------------------|
| `publisher` | `Publisher` <br /> |

|                                             Returns                                              ||
|------------------------------------------------------------------------------------------|--------|
| [LiveData](https://developer.android.com/reference/android/arch/lifecycle/LiveData)`<T>` | <br /> |

### toPublisher

added in[version 1.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Adapts the given[LiveData](https://developer.android.com/reference/android/arch/lifecycle/LiveData)stream to a ReactiveStreams[Publisher](https://developer.android.com/reference/org/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)](https://developer.android.com/reference/org/reactivestreams/Subscription#request(long)).

On subscription to the publisher, the observer will attach to the given[LiveData](https://developer.android.com/reference/android/arch/lifecycle/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.

<br />

|              Parameters              ||
|-------------|-------------------------|
| `lifecycle` | `LifecycleOwner` <br /> |
| `liveData`  | `LiveData` <br />       |

|        Returns         ||
|----------------|--------|
| `Publisher<T>` | <br /> |

-

  ## Annotations

  - [OnLifecycleEvent](https://developer.android.com/reference/android/arch/lifecycle/OnLifecycleEvent)
-

  ## Interfaces

  - [DefaultLifecycleObserver](https://developer.android.com/reference/android/arch/lifecycle/DefaultLifecycleObserver)
  - [LifecycleObserver](https://developer.android.com/reference/android/arch/lifecycle/LifecycleObserver)
  - [LifecycleOwner](https://developer.android.com/reference/android/arch/lifecycle/LifecycleOwner)
  - [LifecycleRegistryOwner](https://developer.android.com/reference/android/arch/lifecycle/LifecycleRegistryOwner)
  - [Observer](https://developer.android.com/reference/android/arch/lifecycle/Observer)
  - [ViewModelProvider.Factory](https://developer.android.com/reference/android/arch/lifecycle/ViewModelProvider.Factory)
  - [ViewModelStoreOwner](https://developer.android.com/reference/android/arch/lifecycle/ViewModelStoreOwner)
-

  ## Classes

  - [AndroidViewModel](https://developer.android.com/reference/android/arch/lifecycle/AndroidViewModel)
  - [Lifecycle](https://developer.android.com/reference/android/arch/lifecycle/Lifecycle)
  - [LifecycleRegistry](https://developer.android.com/reference/android/arch/lifecycle/LifecycleRegistry)
  - [LifecycleService](https://developer.android.com/reference/android/arch/lifecycle/LifecycleService)
  - [LiveData](https://developer.android.com/reference/android/arch/lifecycle/LiveData)
  - [LiveDataReactiveStreams](https://developer.android.com/reference/android/arch/lifecycle/LiveDataReactiveStreams)
  - [MediatorLiveData](https://developer.android.com/reference/android/arch/lifecycle/MediatorLiveData)
  - [MutableLiveData](https://developer.android.com/reference/android/arch/lifecycle/MutableLiveData)
  - [ProcessLifecycleOwner](https://developer.android.com/reference/android/arch/lifecycle/ProcessLifecycleOwner)
  - [ServiceLifecycleDispatcher](https://developer.android.com/reference/android/arch/lifecycle/ServiceLifecycleDispatcher)
  - [Transformations](https://developer.android.com/reference/android/arch/lifecycle/Transformations)
  - [ViewModel](https://developer.android.com/reference/android/arch/lifecycle/ViewModel)
  - [ViewModelProvider](https://developer.android.com/reference/android/arch/lifecycle/ViewModelProvider)
  - [ViewModelProvider.AndroidViewModelFactory](https://developer.android.com/reference/android/arch/lifecycle/ViewModelProvider.AndroidViewModelFactory)
  - [ViewModelProvider.NewInstanceFactory](https://developer.android.com/reference/android/arch/lifecycle/ViewModelProvider.NewInstanceFactory)
  - [ViewModelProviders](https://developer.android.com/reference/android/arch/lifecycle/ViewModelProviders)
  - [ViewModelProviders.DefaultFactory](https://developer.android.com/reference/android/arch/lifecycle/ViewModelProviders.DefaultFactory)
  - [ViewModelStore](https://developer.android.com/reference/android/arch/lifecycle/ViewModelStore)
  - [ViewModelStores](https://developer.android.com/reference/android/arch/lifecycle/ViewModelStores)
-

  ## Enums

  - [Lifecycle.Event](https://developer.android.com/reference/android/arch/lifecycle/Lifecycle.Event)
  - [Lifecycle.State](https://developer.android.com/reference/android/arch/lifecycle/Lifecycle.State)