# InvalidationTracker.Observer

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/room/InvalidationTracker.Observer "View this page in Java")
Common/AllAndroid/JVMNative/C/iOSJavaScript
  - android  

  ```
  abstract class InvalidationTracker.Observer
  ```

*** ** * ** ***

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

## Summary

|                                                                                                                                            ### Public constructors                                                                                                                                             |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
| [Observer](https://developer.android.com/reference/kotlin/androidx/room/InvalidationTracker.Observer#Observer(kotlin.Array))`(tables: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`>)` | android |

|                                                                                                                                                                                     ### Protected constructors                                                                                                                                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
| [Observer](https://developer.android.com/reference/kotlin/androidx/room/InvalidationTracker.Observer#Observer(kotlin.String,kotlin.Array))`(firstTable: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`, vararg rest: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Creates an observer for the given tables and views. | android |

|                                   ### Public functions                                   |
|------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
| `abstract `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onInvalidated](https://developer.android.com/reference/kotlin/androidx/room/InvalidationTracker.Observer#onInvalidated(kotlin.collections.Set))`(tables: `[Set](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html)`<`[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`>)` Invoked when one of the observed tables is invalidated (changed). | android |

## Public constructors

### Observer

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

```
Observer(tables: Array<String>)
```  

|                                                                                    Parameters                                                                                    |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
| `tables: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`>` | The names of the tables this observer is interested in getting notified if they are modified. |

## Protected constructors

### Observer

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

```
protected Observer(firstTable: String, vararg rest: String)
```

Creates an observer for the given tables and views.  

|                                            Parameters                                            |
|--------------------------------------------------------------------------------------------------|--------------------------------|
| `firstTable: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)  | The name of the table or view. |
| `vararg rest: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | More names of tables or views. |

## Public functions

### onInvalidated

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

```
abstract fun onInvalidated(tables: Set<String>): Unit
```

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

|                                                                                        Parameters                                                                                        |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `tables: `[Set](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html)`<`[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`>` | 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. |