# Updater

Artifact: [androidx.compose.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/Composer.kt+class:androidx.compose.runtime.Updater) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0) Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  value class Updater<T : Any?>
  ```

*** ** * ** ***

A helper receiver scope class used by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposeNode.composable#ComposeNode(kotlin.Function0,kotlin.Function1)` to help write code to initialized and update a node.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposeNode.composable#ComposeNode(kotlin.Function0,kotlin.Function1)` |   |

## Summary

| ### Public constructors |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#Updater(androidx.compose.runtime.Composer)(composer: https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composer)` | Cmn |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#init(kotlin.Function1)(block: T.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Initialize emitted node. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<V : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#init(kotlin.Any,kotlin.Function2)(value: V, block: T.(V) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Initialize emitted node. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#reconcile(kotlin.Function1)(block: T.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Reconcile the node to the current state. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<V : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#set(kotlin.Any,kotlin.Function2)(value: V, block: T.(value) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Set the value property of the emitted node. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<V : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#update(kotlin.Any,kotlin.Function2)(value: V, block: T.(value) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Update the value of a property of the emitted node. | Cmn |

## Public constructors

### Updater

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

```
<T : Any?> Updater(composer: Composer)
```

## Public functions

### init

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

```
fun init(block: T.() -> Unit): Unit
```

Initialize emitted node.

Schedule `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#init(kotlin.Function1)` to be executed after the node is created.

This is only executed once. The can be used to call a method or set a value on a node instance that is required to be set after one or more other properties have been set.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#reconcile(kotlin.Function1)` |   |

### init

Cmn

```
fun <V : Any?> init(value: V, block: T.(V) -> Unit): Unit
```

Initialize emitted node.

Schedule `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#init(kotlin.Any,kotlin.Function2)` to be executed after the node is created.

This is only executed once. The can be used to call a method or set a value on a node instance that is required to be set after one or more other properties have been set.

This is different from the other `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#init(kotlin.Any,kotlin.Function2)` overload in that it does not force creating a lambda to capture `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#init(kotlin.Any,kotlin.Function2)`.

### reconcile

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

```
fun reconcile(block: T.() -> Unit): Unit
```

Reconcile the node to the current state.

This is used when `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#set(kotlin.Any,kotlin.Function2)` and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#update(kotlin.Any,kotlin.Function2)` are insufficient to update the state of the node based on changes passed to the function calling `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposeNode.composable#ComposeNode(kotlin.Function0,kotlin.Function1)`.

Schedules `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#reconcile(kotlin.Function1)` to execute. As this unconditionally schedules `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#reconcile(kotlin.Function1)` to executed it might be executed unnecessarily as no effort is taken to ensure it only executes when the values `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#reconcile(kotlin.Function1)` captures have changed. It is highly recommended that `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#set(kotlin.Any,kotlin.Function2)` and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#update(kotlin.Any,kotlin.Function2)` be used instead as they will only schedule their blocks to executed when the value passed to them has changed.

### set

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

```
fun <V : Any?> set(value: V, block: T.(value) -> Unit): Unit
```

Set the value property of the emitted node.

Schedules `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#set(kotlin.Any,kotlin.Function2)` to be run when the node is first created or when `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#set(kotlin.Any,kotlin.Function2)` is different than the previous composition.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#update(kotlin.Any,kotlin.Function2)` |   |

### update

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

```
fun <V : Any?> update(value: V, block: T.(value) -> Unit): Unit
```

Update the value of a property of the emitted node.

Schedules `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#update(kotlin.Any,kotlin.Function2)` to be run when `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#update(kotlin.Any,kotlin.Function2)` is different than the previous composition. It is different than `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#set(kotlin.Any,kotlin.Function2)` in that it does not run when the node is created. This is used when initial value set by the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposeNode.composable#ComposeNode(kotlin.Function0,kotlin.Function1)` in the constructor callback already has the correct value. For example, use \[update} when `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#update(kotlin.Any,kotlin.Function2)` is passed into of the classes constructor parameters.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Updater#set(kotlin.Any,kotlin.Function2)` |   |