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

SnapshotStateExtensionsKt

public final class SnapshotStateExtensionsKt


Summary

Public methods

static final @NonNull DoubleState

Converts a State<Double> (as in, a State of boxed Doubles) into a primitive-backed Double.

static final @NonNull FloatState

Converts a State<Float> (as in, a State of boxed Floats) into a primitive-backed Float.

static final @NonNull IntState

Converts a State<Int> (as in, a State of boxed Ints) into a primitive-backed IntState.

static final @NonNull LongState

Converts a State<Long> (as in, a State of boxed Longs) into a primitive-backed LongState.

Public methods

asDoubleState

public static final @NonNull DoubleState asDoubleState(@NonNull State<@NonNull Double> receiver)

Converts a State<Double> (as in, a State of boxed Doubles) into a primitive-backed Double. The state will be automatically unboxed to the required primitive type. The returned state is read-only. The returned state will mirror the values of the base state and apply updates in the same way as the receiver defines.

On the JVM, this conversion does not avoid the autoboxing that Double attempts to escape, but instead is intended to allow interoperability between components that use either representation of a state of type Double.

asFloatState

public static final @NonNull FloatState asFloatState(@NonNull State<@NonNull Float> receiver)

Converts a State<Float> (as in, a State of boxed Floats) into a primitive-backed Float. The state will be automatically unboxed to the required primitive type. The returned state is read-only. The returned state will mirror the values of the base state and apply updates in the same way as the receiver defines.

On the JVM, this conversion does not avoid the autoboxing that Float attempts to escape, but instead is intended to allow interoperability between components that use either representation of a state of type Float.

asIntState

public static final @NonNull IntState asIntState(@NonNull State<@NonNull Integer> receiver)

Converts a State<Int> (as in, a State of boxed Ints) into a primitive-backed IntState. The state will be automatically unboxed to the required primitive type. The returned state is read-only. The returned state will mirror the values of the base state and apply updates in the same way as the receiver defines.

On the JVM, this conversion does not avoid the autoboxing that IntState attempts to escape, but instead is intended to allow interoperability between components that use either representation of a state of type Int.

asLongState

public static final @NonNull LongState asLongState(@NonNull State<@NonNull Long> receiver)

Converts a State<Long> (as in, a State of boxed Longs) into a primitive-backed LongState. The state will be automatically unboxed to the required primitive type. The returned state is read-only. The returned state will mirror the values of the base state and apply updates in the same way as the receiver defines.

On the JVM, this conversion does not avoid the autoboxing that LongState attempts to escape, but instead is intended to allow interoperability between components that use either representation of a state of type Long.