# InvalidationTracker.Observer

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

*** ** * ** ***


```
public abstract class InvalidationTracker.Observer
```

<br />

*** ** * ** ***

An observer that can listen for changes in the database by subscribing to an `https://developer.android.com/reference/androidx/room/InvalidationTracker`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/room/InvalidationTracker.Observer#Observer(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull String[] tables)` |

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/androidx/room/InvalidationTracker.Observer#Observer(kotlin.String,kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html firstTable, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html... rest)` Creates an observer for the given tables and views. |

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/room/InvalidationTracker.Observer#onInvalidated(kotlin.collections.Set)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html> tables)` Invoked when one of the observed tables is invalidated (changed). |

## Public constructors

### Observer

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

```
public Observer(@NonNull String[] tables)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull String[] tables` | The names of the tables this observer is interested in getting notified if they are modified. |

## Protected constructors

### Observer

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

```
protected Observer(@NonNull String firstTable, @NonNull String... rest)
```

Creates an observer for the given tables and views.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html firstTable` | The name of the table or view. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html... rest` | More names of tables or views. |

## Public methods

### onInvalidated

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

```
public abstract void onInvalidated(@NonNull Set<@NonNull String> tables)
```

Invoked when one of the observed tables is invalidated (changed).

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html> tables` | A set of invalidated tables. When the observer is interested in multiple tables, this set can be used to distinguish which of the observed tables were invalidated. When observing a database view the names of underlying tables will be in the set instead of the view name. |