# RxDataStore

Artifact: [androidx.datastore:datastore-rxjava3](https://developer.android.com/jetpack/androidx/releases/datastore) [View Source](https://cs.android.com/search?q=file:androidx/datastore/rxjava3/RxDataStore.kt+class:androidx.datastore.rxjava3.RxDataStore) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0)

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/androidx/datastore/rxjava3/RxDataStore "View this page in Java")


```
class RxDataStore<T : Any> : Disposable
```

<br />

*** ** * ** ***

A DataStore that supports RxJava operations on DataStore.

## Summary

| ### Public functions |
|---|---|
| `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html<T>` | `@https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-experimental-coroutines-api/index.html https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxDataStore#data()()` Gets a reactivex.Flowable of the data from DataStore. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxDataStore#dispose()()` Dispose of the DataStore. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxDataStore#isDisposed()()` Returns whether this DataStore is closed |
| `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Completable.html` | `https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxDataStore#shutdownComplete()()` Returns a completable that completes when the DataStore is completed. |
| `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html<T>` | `@https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-experimental-coroutines-api/index.html https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxDataStore#updateDataAsync(io.reactivex.rxjava3.functions.Function)(transform: http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/functions/Function.html<T, http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html<T>>)` See `https://developer.android.com/reference/kotlin/androidx/datastore/core/DataStore#updateData(kotlin.coroutines.SuspendFunction1)` |

| ### Public properties |
|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxDataStore#isDisposed()` |

## Public functions

### data

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0)

```
@ExperimentalCoroutinesApi
fun data(): Flowable<T>
```

Gets a reactivex.Flowable of the data from DataStore. See `https://developer.android.com/reference/kotlin/androidx/datastore/core/DataStore#data()` for more information.

Provides efficient, cached (when possible) access to the latest durably persisted state. The flow will always either emit a value or throw an exception encountered when attempting to read from disk. If an exception is encountered, collecting again will attempt to read the data again.

Do not layer a cache on top of this API: it will be be impossible to guarantee consistency. Instead, use data.first() to access a single snapshot.

The Flowable will complete with an IOException when an exception is encountered when reading data.

| Returns |
|---|---|
| `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html<T>` | a flow representing the current state of the data |

### dispose

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0)

```
open fun dispose(): Unit
```

Dispose of the DataStore. Wait for the Completable returned by `https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxDataStore#shutdownComplete()` to confirm that the DataStore has been shut down.

### isDisposed

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0)

```
open fun isDisposed(): Boolean
```

Returns whether this DataStore is closed

### shutdownComplete

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0)

```
fun shutdownComplete(): Completable
```

Returns a completable that completes when the DataStore is completed. It is not safe to create a new DataStore with the same file name until this has completed.

### updateDataAsync

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0)

```
@ExperimentalCoroutinesApi
fun updateDataAsync(transform: Function<T, Single<T>>): Single<T>
```

See `https://developer.android.com/reference/kotlin/androidx/datastore/core/DataStore#updateData(kotlin.coroutines.SuspendFunction1)`

Updates the data transactionally in an atomic read-modify-write operation. All operations are serialized, and the transform itself is a async so it can perform heavy work such as RPCs.

The Single completes when the data has been persisted durably to disk (after which `https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxDataStore#data()` will reflect the update). If the transform or write to disk fails, the transaction is aborted and the returned Single is completed with the error.

The transform will be run on the scheduler that DataStore was constructed with.

| Returns |
|---|---|
| `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html<T>` | the snapshot returned by the transform |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-exception/index.html` | when thrown by the transform function |

## Public properties

### isDisposed

Added in 1.0.0

```
open val isDisposed: Boolean
```