{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

Updater

@<Error class: unknown class>
value public final class Updater<T extends Object>


A helper receiver scope class used by ComposeNode to help write code to initialized and update a node.

See also
ComposeNode

Summary

Public constructors

<T extends Object> Updater(@NonNull Composer composer)

Public methods

final void
init(@ExtensionFunctionType @NonNull Function1<@NonNull T, Unit> block)

Initialize emitted node.

final void

Reconcile the node to the current state.

final void
set(
    int value,
    @ExtensionFunctionType @NonNull Function2<@NonNull T, @NonNull IntegerUnit> block
)

Set the value property of the emitted node.

final void
<V extends Object> set(
    @NonNull V value,
    @ExtensionFunctionType @NonNull Function2<@NonNull T, @NonNull value, Unit> block
)

Set the value property of the emitted node.

final void
update(
    int value,
    @ExtensionFunctionType @NonNull Function2<@NonNull T, @NonNull IntegerUnit> block
)

Update the value of a property of the emitted node.

final void
<V extends Object> update(
    @NonNull V value,
    @ExtensionFunctionType @NonNull Function2<@NonNull T, @NonNull value, Unit> block
)

Update the value of a property of the emitted node.

Public constructors

Updater

public <T extends Object> Updater(@NonNull Composer composer)

Public methods

init

public final void init(@ExtensionFunctionType @NonNull Function1<@NonNull T, Unit> block)

Initialize emitted node.

Schedule block 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
reconcile

reconcile

public final void reconcile(@ExtensionFunctionType @NonNull Function1<@NonNull T, Unit> block)

Reconcile the node to the current state.

This is used when set and update are insufficient to update the state of the node based on changes passed to the function calling ComposeNode.

Schedules block to execute. As this unconditionally schedules block to executed it might be executed unnecessarily as no effort is taken to ensure it only executes when the values block captures have changed. It is highly recommended that set and update be used instead as they will only schedule their blocks to executed when the value passed to them has changed.

set

public final void set(
    int value,
    @ExtensionFunctionType @NonNull Function2<@NonNull T, @NonNull IntegerUnit> block
)

Set the value property of the emitted node.

Schedules block to be run when the node is first created or when value is different than the previous composition.

See also
update

set

public final void <V extends Object> set(
    @NonNull V value,
    @ExtensionFunctionType @NonNull Function2<@NonNull T, @NonNull value, Unit> block
)

Set the value property of the emitted node.

Schedules block to be run when the node is first created or when value is different than the previous composition.

See also
update

update

public final void update(
    int value,
    @ExtensionFunctionType @NonNull Function2<@NonNull T, @NonNull IntegerUnit> block
)

Update the value of a property of the emitted node.

Schedules block to be run when value is different than the previous composition. It is different than set in that it does not run when the node is created. This is used when initial value set by the ComposeNode in the constructor callback already has the correct value. For example, use [update} when value is passed into of the classes constructor parameters.

See also
set

update

public final void <V extends Object> update(
    @NonNull V value,
    @ExtensionFunctionType @NonNull Function2<@NonNull T, @NonNull value, Unit> block
)

Update the value of a property of the emitted node.

Schedules block to be run when value is different than the previous composition. It is different than set in that it does not run when the node is created. This is used when initial value set by the ComposeNode in the constructor callback already has the correct value. For example, use [update} when value is passed into of the classes constructor parameters.

See also
set