# RxRoom

Artifact: [androidx.room:room-rxjava2](https://developer.android.com/jetpack/androidx/releases/room) [View Source](https://cs.android.com/search?q=file:androidx/room/RxRoom.kt+class:androidx.room.RxRoom) Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/room#2.0.0)

*** ** * ** ***


```
public class RxRoom
```

<br />

*** ** * ** ***

## Summary

| ### Public fields |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/room/RxRoom#NOTHING()` Data dispatched by the publisher created by `https://developer.android.com/reference/androidx/room/RxRoom.Companion#createFlowable(androidx.room.RoomDatabase,kotlin.Boolean,kotlin.Array,kotlin.Function1)`. |

| ### Public constructors |
|---|
| `[RxRoom](https://developer.android.com/reference/androidx/room/RxRoom#RxRoom())()` **This method is deprecated.** This type should not be instantiated as it contains only utility functions. |

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html>` | `https://developer.android.com/reference/androidx/room/RxRoom#createFlowable(androidx.room.RoomDatabase,kotlin.Array)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room/RoomDatabase database, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html... tableNames )` Creates a `https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html` that emits at least once and also re-emits whenever one of the observed tables is updated. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Observable.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html>` | `https://developer.android.com/reference/androidx/room/RxRoom#createObservable(androidx.room.RoomDatabase,kotlin.Array)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room/RoomDatabase database, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html... tableNames )` Creates a `https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Observable.html` that emits at least once and also re-emits whenever one of the observed tables is updated. |

## Public fields

### NOTHING

```
public static final @NonNull Object NOTHING
```

Data dispatched by the publisher created by `https://developer.android.com/reference/androidx/room/RxRoom.Companion#createFlowable(androidx.room.RoomDatabase,kotlin.Boolean,kotlin.Array,kotlin.Function1)`.

## Public constructors

### RxRoom

Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/room#2.0.0) Deprecated in [2.0.0](https://developer.android.com/jetpack/androidx/releases/room#2.0.0)

```
public [RxRoom](https://developer.android.com/reference/androidx/room/RxRoom#RxRoom())()
```

> [!CAUTION]
> **This method is deprecated.**   
> This type should not be instantiated as it contains only utility functions.

## Public methods

### createFlowable

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

```
public static final @NonNull Flowable<@NonNull Object> createFlowable(
    @NonNull RoomDatabase database,
    @NonNull String... tableNames
)
```

Creates a `https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html` that emits at least once and also re-emits whenever one of the observed tables is updated.

You can easily chain a database operation to downstream of this `https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html` to ensure that it re-runs when database is modified.

Since database invalidation is batched, multiple changes in the database may results in just 1 emission.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room/RoomDatabase database` | The database instance |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html... tableNames` | The list of table names that should be observed |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html>` | A `https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html` which emits `https://developer.android.com/reference/androidx/room/RxRoom#NOTHING()` when one of the observed tables is modified (also once when the invalidation tracker connection is established). |

### createObservable

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

```
public static final @NonNull Observable<@NonNull Object> createObservable(
    @NonNull RoomDatabase database,
    @NonNull String... tableNames
)
```

Creates a `https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Observable.html` that emits at least once and also re-emits whenever one of the observed tables is updated.

You can easily chain a database operation to downstream of this `https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Observable.html` to ensure that it re-runs when database is modified.

Since database invalidation is batched, multiple changes in the database may results in just 1 emission.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room/RoomDatabase database` | The database instance |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html... tableNames` | The list of table names that should be observed |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Observable.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html>` | A `https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Observable.html` which emits .NOTHING when one of the observed tables is modified (also once when the invalidation tracker connection is established). |