# ObserverModifierNode

Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/node/ObserverModifierNode.kt+class:androidx.compose.ui.node.ObserverModifierNode) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.5.0) Common/AllAndroid/JVM
- Cmn

  ```
  interface ObserverModifierNode : DelegatableNode
  ```

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.Node`s that implement ObserverNode can provide their own implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/ObserverModifierNode#onObservedReadsChanged()` that will be called in response to changes to snapshot objects read within an `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/package-summary#(androidx.compose.ui.Modifier.Node).observeReads(kotlin.Function0)` block.

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/ObserverModifierNode#onObservedReadsChanged()()` This callback is called when any values that are read within the `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/package-summary#(androidx.compose.ui.Modifier.Node).observeReads(kotlin.Function0)` block change. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.Node & https://developer.android.com/reference/kotlin/androidx/compose/ui/node/ObserverModifierNode> T.https://developer.android.com/reference/kotlin/androidx/compose/ui/node/ObserverModifierNode#(androidx.compose.ui.Modifier.Node).observeReads(kotlin.Function0)(block: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Use this function to observe snapshot reads for any target within the specified `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/package-summary#(androidx.compose.ui.Modifier.Node).observeReads(kotlin.Function0)`. | Cmn |

### Inherited functions

From [androidx.compose.ui.node.DelegatableNode](https://developer.android.com/reference/kotlin/androidx/compose/ui/node/DelegatableNode) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/EmptySuper
https://developer.android.com/reference/kotlin/androidx/compose/ui/node/DelegatableNode#onDensityChange()()`

Invoked when the density changes for this node.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/EmptySuper
https://developer.android.com/reference/kotlin/androidx/compose/ui/node/DelegatableNode#onLayoutDirectionChange()()`

Invoked when the layout direction changes for this node.
Cmn

### Inherited properties

From [androidx.compose.ui.node.DelegatableNode](https://developer.android.com/reference/kotlin/androidx/compose/ui/node/DelegatableNode) `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.Node` `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/DelegatableNode#node()`

A reference of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.Node` that holds this node's position in the node hierarchy.
Cmn

## Public functions

### onObservedReadsChanged

Cmn Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.5.0)

```
fun onObservedReadsChanged(): Unit
```

This callback is called when any values that are read within the `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/package-summary#(androidx.compose.ui.Modifier.Node).observeReads(kotlin.Function0)` block change. It is called after the snapshot is committed. `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/ObserverModifierNode#onObservedReadsChanged()` is called on the UI thread, and only called once in response to snapshot observation. To continue observing further updates, you need to call `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/package-summary#(androidx.compose.ui.Modifier.Node).observeReads(kotlin.Function0)` again.

## Extension functions

### T.observeReads

Cmn Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/node/ObserverModifierNode.kt+function:observeReads)

```
fun <T : Modifier.Node & ObserverModifierNode> T.observeReads(block: () -> Unit): Unit
```

Use this function to observe snapshot reads for any target within the specified `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/package-summary#(androidx.compose.ui.Modifier.Node).observeReads(kotlin.Function0)`. `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/ObserverModifierNode#onObservedReadsChanged()` is called when any of the observed values within the snapshot change.