이제 두 번째 Android 11 개발자 프리뷰를 사용할 수 있습니다. 테스트해 보고 의견을 공유하세요.

androidx.compose

Classes

Ambient

Compose passes data through the composition tree explicitly through means of parameters to composable functions.

Anchor

Applier

A helper class to apply changes to a tree with startNode types N given an apply adapter for type N

BitSet

Composer

Implementation of a composer for mutable tree.

ComposerUpdater

KeyInfo

Information about groups and their keys.

Looper

ObserverMap

A map from a key to a set of values used for keeping the relation between some entities and a models changes of which this entities are observing.

ProvidableAmbient

A ProvidableAmbient can be used in Providers to provide values.

ProvidedValue

An instance to hold a value provided by Providers and is created by the ProvidableAmbient.provides infixed operator.

Recomposer

Reference

ReferenceQueue

SlotReader

SlotTable

A gap buffer implementation of the composition slot space.

SlotWriter

WeakHashMap

WeakReference

Annotations

CheckResult

Composable

Composable functions are the fundamental building blocks of an application built with Compose.

Immutable

MainThread

Model

Model can be applied to a class which represents your application's data model, and will cause instances of the class to become observable, such that a read of a property of an instance of this class during the invocation of a composable function will cause that component to be "subscribed" to mutations of that instance.

Pivotal

Pivotal can be applied to the parameters of a composable to indicate that the parameter contributes to the "identity" of the composable.

Stable

StableMarker

StableMarker marks an annotation as indicating a type as having a stable equals comparision that can be used during composition.

TestOnly

UnionType

Untracked

When applied to a function expression Untracked will disable lambda optimizations such as tracking execution of composable function expressions or remembering a function expression value based on its capture variables.

Top-level constants summary

const Int

const Int

Top-level functions summary

Unit
Observe(body: () -> Unit)

This component creates a scope which will be the root of recomposition for any reads or writes to Model classes that happen inside of it.

Unit
Providers(vararg values: ProvidedValue<*>, children: () -> Unit)

Providers binds values to ProvidableAmbient keys.

Unit
Recompose(body: (recompose: () -> Unit) -> Unit)

Recompose is a component which passes a "recompose" function to its children which, when invoked, will cause its children to recompose.

ProvidableAmbient<T>
ambientOf(areEquivalent: (old: T, new: T) -> Boolean = ReferentiallyEqual, defaultFactory: () -> T = null)

Create an ambient key that can be provided using Providers.

Composition
compositionFor(container: Any, parent: CompositionReference? = null, composerFactory: (SlotTable, Recomposer) -> Composer<*>)

This method is the way to initiate a composition.

CompositionReference

An Effect to construct a CompositionReference at the current point of composition.

() -> Unit

Represents empty content for a Composable function.

T

Boolean

Any?

Any?

T
key(@Pivotal v1: V1, block: () -> T)

key is a utility composable that is used to "group" or "key" a block of execution inside of a composition.

T
key(@Pivotal v1: V1, @Pivotal v2: V2, block: () -> T)

key is a utility composable that is used to "group" or "key" a block of execution inside of a composition.

T
key(@Pivotal vararg inputs: Any?, block: () -> T)

key is a utility composable that is used to "group" or "key" a block of execution inside of a composition.

actual String?

MutableState<T>
mutableStateOf(value: T, areEquivalent: (old: T, new: T) -> Boolean = ReferentiallyEqual)

Return a new MutableState initialized with the passed in value

Unit
onActive(callback: CommitScope.() -> Unit)

An effect used to observe the lifecycle of the composition.

Unit
onCommit(noinline callback: CommitScope.() -> Unit)

The onCommit effect is a lifecycle effect that will execute callback every time the composition commits.

Unit
onCommit(v1: V1, callback: CommitScope.() -> Unit)

The onCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed.

Unit
onCommit(v1: V1, v2: V2, callback: CommitScope.() -> Unit)

The onCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed.

Unit
onCommit(vararg inputs: Any?, callback: CommitScope.() -> Unit)

The onCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed.

Unit
onDispose(callback: () -> Unit)

An effect used to schedule work to be done when the effect leaves the composition.

Unit
onPreCommit(noinline callback: CommitScope.() -> Unit)

The onPreCommit effect is a lifecycle effect that will execute callback every time the composition commits, but before those changes have been reflected on the screen.

Unit
onPreCommit(v1: V1, callback: CommitScope.() -> Unit)

The onPreCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed, but before those changes have been reflected on the screen.

Unit
onPreCommit(v1: V1, v2: V2, callback: CommitScope.() -> Unit)

The onPreCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed, but before those changes have been reflected on the screen.

Unit
onPreCommit(vararg inputs: Any?, callback: CommitScope.() -> Unit)

The onPreCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed, but before those changes have been reflected on the screen.

T
remember(calculation: () -> T)

Remember the value produced by calculation.

T
remember(v1: V1, calculation: () -> T)

Remember the value returned by calculation if v1 is equal to the previous composition, otherwise produce and remember a new value by calling calculation.

T
remember(v1: V1, v2: V2, calculation: () -> T)

Remember the value returned by calculation if v1 and v2 are equal to the previous composition, otherwise produce and remember a new value by calling calculation.

T
remember(v1: V1, v2: V2, v3: V3, calculation: () -> T)

Remember the value returned by calculation if v1, v2 and v3 are equal to the previous composition, otherwise produce and remember a new value by calling calculation.

V
remember(vararg inputs: Any?, block: () -> V)

Remember the value returned by block if all values of inputs are equal to the previous composition, otherwise produce and remember a new value by calling block.

MutableState<T>
state(noinline areEquivalent: (old: T, new: T) -> Boolean = ReferentiallyEqual, init: () -> T)

A composable used to introduce a state value of type T into a composition.

MutableState<T>
stateFor(v1: V1, init: () -> T)

An effect to introduce a state value of type T into a composition that will last as long as the input v1 does not change.

MutableState<T>
stateFor(v1: V1, v2: V2, init: () -> T)

An effect to introduce a state value of type T into a composition that will last as long as the inputs v1 and v2 do not change.

MutableState<T>
stateFor(vararg inputs: Any?, init: () -> T)

An effect to introduce a state value of type T into a composition that will last as long as the inputs inputs do not change.

ProvidableAmbient<T>
staticAmbientOf(defaultFactory: () -> T = null)

Create an ambient key that can be provided using Providers.

Top-level properties summary

(Any?, Any?) -> Boolean

Simple comparison callback that always returns false, for mutable objects that will be compared with the same reference.

(Any?, Any?) -> Boolean

Simple comparison callback using referential === equality

(Any?, Any?) -> Boolean

Simple comparison callback using structural Any.equals equality

UiComposer

Composer<*>

() -> Unit

An Effect to get the nearest invalidation lambda to the current point of composition.

Extension functions summary

For kotlin.Function0
() -> Unit
() -> Unit.orEmpty()

For Composer
T
Composer<N>.cache(valid: Boolean = true, block: () -> T)

Cache a value in the composition.

Any?

Get the next value of the slot table.

Top-level constants

DEFAULT_SLOT_ACTIONS_SIZE

const val DEFAULT_SLOT_ACTIONS_SIZE: Int
Value: 16

DEFAULT_SLOT_KEYS_SIZE

const val DEFAULT_SLOT_KEYS_SIZE: Int
Value: 8

Top-level functions

Observe

@Composable fun Observe(body: () -> Unit): Unit

This component creates a scope which will be the root of recomposition for any reads or writes to Model classes that happen inside of it. This can be used to improve performance in situations where you know that a specific Model object will need to change at high frequencies, and you want to reduce the burden of recomposition. It is recommended that you not introduce Observe into the composition until it is clear that is necessary to improve performance.

Parameters
body: () -> Unit The composable content to observe

Providers

@Composable fun Providers(
    vararg values: ProvidedValue<*>,
    children: () -> Unit
): Unit

Providers binds values to ProvidableAmbient keys. Reading the ambient using Ambient.current will return the value provided in Providers's values parameter for all composable functions called directly or indirectly in the children lambda.


//Unresolved: androidx.compose.samples.ambientProvider

Recompose

@Composable fun Recompose(body: (recompose: () -> Unit) -> Unit): Unit

Recompose is a component which passes a "recompose" function to its children which, when invoked, will cause its children to recompose. This is useful if you are updating local state and need to cause a recomposition manually.

In most cases we recommend using Model classes or state with immutable types in order to maintain local state inside of composables. For cases where this is impractical, Recompose can help you.

Example:


//Unresolved: androidx.compose.samples.recomposeSample
Note: The above example can be done without Recompose by annotating LoginState with Model.

ambientOf

fun <T> ambientOf(
    areEquivalent: (old: T, new: T) -> Boolean = ReferentiallyEqual,
    defaultFactory: () -> T = null
): ProvidableAmbient<T>

Create an ambient key that can be provided using Providers. Changing the value provided during recomposition will invalidate the children of Providers that read the value using Ambient.current.

compositionFor

fun compositionFor(
    container: Any,
    parent: CompositionReference? = null,
    composerFactory: (SlotTable, Recomposer) -> Composer<*>
): Composition

This method is the way to initiate a composition. Optionally, a parent can be provided to make the composition behave as a sub-composition of the parent. The children of container will be updated and maintained by the time this method returns.

It is important to call Composition.dispose whenever this container is no longer needed in order to release resources.

Parameters
container: Any The container whose content is being composed.
parent: CompositionReference? = null The parent composition reference, if applicable. Default is null.
composerFactory: (SlotTable, Recomposer) -> Composer<*> The factory used to created a Composer to be used by the composition.

compositionReference

@Composable fun compositionReference(): CompositionReference

An Effect to construct a CompositionReference at the current point of composition. This can be used to run a separate composition in the context of the current one, preserving ambients and propagating invalidations.

emptyContent

fun emptyContent(): () -> Unit

Represents empty content for a Composable function.

See orEmpty for handling nullable Composable lambdas using empty content.

escapeCompose

inline fun <T> escapeCompose(block: NullCompilationScope.() -> T): T

isJoinedKey

fun isJoinedKey(key: Any?): Boolean

joinedKeyLeft

fun joinedKeyLeft(key: Any?): Any?

joinedKeyRight

fun joinedKeyRight(key: Any?): Any?

key

@Composable inline fun <T, V1> key(
    @Pivotal v1: V1,
    block: () -> T
): T

key is a utility composable that is used to "group" or "key" a block of execution inside of a composition. This is sometimes needed for correctness inside of control-flow that may cause a given composable invocation to execute more than once during composition.

The value for a key does not need to be globally unique, and needs only be unique amongst the invocations of key at that point in composition.

For instance, consider the following example:


//Unresolved: androidx.compose.samples.locallyUniqueKeys

Even though there are users with the same id composed in both the top and the bottom loop, because they are different calls to key, there is no need to create compound keys.

The key must be unique for each element in the collection, however, or children and local state might be reused in unintended ways.

For instance, consider the following example:


//Unresolved: androidx.compose.samples.notAlwaysUniqueKeys
This example assumes that parent.id is a unique key for each item in the collection,but this is only true if it is fair to assume that a parent will only ever have a single child,which may not be the case. Instead, it may be more correct to do the following:

//Unresolved: androidx.compose.samples.moreCorrectUniqueKeys
Parameters
v1: V1 The value used to identify this group. The value will be compared for equality using equals and hashed using hashCode.
block: () -> T The composable children for this group.

See Also

key

@Composable inline fun <T, V1, V2> key(
    @Pivotal v1: V1,
    @Pivotal v2: V2,
    block: () -> T
): T

key is a utility composable that is used to "group" or "key" a block of execution inside of a composition. This is sometimes needed for correctness inside of control-flow that may cause a given composable invocation to execute more than once during composition.

The value for a key does not need to be globally unique, and needs only be unique amongst the invocations of key at that point in composition.

For instance, consider the following example:


//Unresolved: androidx.compose.samples.locallyUniqueKeys

Even though there are users with the same id composed in both the top and the bottom loop, because they are different calls to key, there is no need to create compound keys.

The key must be unique for each element in the collection, however, or children and local state might be reused in unintended ways.

For instance, consider the following example:


//Unresolved: androidx.compose.samples.notAlwaysUniqueKeys
This example assumes that parent.id is a unique key for each item in the collection,but this is only true if it is fair to assume that a parent will only ever have a single child,which may not be the case. Instead, it may be more correct to do the following:

//Unresolved: androidx.compose.samples.moreCorrectUniqueKeys
A compound key can be created by passing in multiple arguments:

//Unresolved: androidx.compose.samples.twoInputsKeySample
Parameters
v1: V1 The first value to use as a key. This will be compared to its previous value using equals
v2: V2 The second value to use as a key. This will be compared to its previous value using equals
block: () -> T The composable children for this group.

key

@Composable inline fun <T> key(
    @Pivotal vararg inputs: Any?,
    block: () -> T
): T

key is a utility composable that is used to "group" or "key" a block of execution inside of a composition. This is sometimes needed for correctness inside of control-flow that may cause a given composable invocation to execute more than once during composition.

The value for a key does not need to be globally unique, and needs only be unique amongst the invocations of key at that point in composition.

For instance, consider the following example:


//Unresolved: androidx.compose.samples.locallyUniqueKeys

Even though there are users with the same id composed in both the top and the bottom loop, because they are different calls to key, there is no need to create compound keys.

The key must be unique for each element in the collection, however, or children and local state might be reused in unintended ways.

For instance, consider the following example:


//Unresolved: androidx.compose.samples.notAlwaysUniqueKeys
This example assumes that parent.id is a unique key for each item in the collection,but this is only true if it is fair to assume that a parent will only ever have a single child,which may not be the case. Instead, it may be more correct to do the following:

//Unresolved: androidx.compose.samples.moreCorrectUniqueKeys
Parameters
vararg inputs: Any? The set of values to be used to create a compound key. These will be compared to their previous values using equals
block: () -> T The composable children for this group.

keySourceInfoOf

actual fun keySourceInfoOf(key: Any): String?

mutableStateOf

fun <T> mutableStateOf(
    value: T,
    areEquivalent: (old: T, new: T) -> Boolean = ReferentiallyEqual
): MutableState<T>

Return a new MutableState initialized with the passed in value

Parameters
value: T the initial value for the MutableState
areEquivalent: (old: T, new: T) -> Boolean = ReferentiallyEqual a callback to compare the previous and new instance of value when it is written to. If this returns true, then no recomposition will be scheduled. See ReferentiallyEqual and StructurallyEqual for simple implementations.

onActive

@Composable fun onActive(callback: CommitScope.() -> Unit): Unit

An effect used to observe the lifecycle of the composition. The callback will execute once initially after the first composition is applied, and then will not fire again. The callback will get executed with a receiver scope that has an onDispose method which can be used to schedule a callback to be executed once whenever the effect leaves the composition

The onActive effect is essentially a convenience effect for onCommit(true) { ... }.

Parameters
callback: CommitScope.() -> Unit The lambda to execute when the composition commits for the first time and becomes active.

onCommit

@Composable inline fun onCommit(noinline callback: CommitScope.() -> Unit): Unit

The onCommit effect is a lifecycle effect that will execute callback every time the composition commits. It is useful for executing code in lock-step with composition that has side-effects. The callback will get executed with a receiver scope that has an onDispose method which can be used to schedule a callback to schedule code that cleans up the code in the callback.

Parameters
callback: CommitScope.() -> Unit The lambda to be executed when the effect is committed to the composition.

onCommit

@Composable fun <V1> onCommit(
    v1: V1,
    callback: CommitScope.() -> Unit
): Unit

The onCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed. It is useful for executing code in lock-step with composition that has side-effects that are based on the inputs. The callback will get executed with a receiver scope that has an onDispose method which can be used to schedule a callback to schedule code that cleans up the code in the callback.

Parameters
v1: V1 The input which will be compared across compositions to determine if callback will get executed.
callback: CommitScope.() -> Unit The lambda to be executed when the effect is committed to the composition.

onCommit

@Composable fun <V1, V2> onCommit(
    v1: V1,
    v2: V2,
    callback: CommitScope.() -> Unit
): Unit

The onCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed. It is useful for executing code in lock-step with composition that has side-effects that are based on the inputs. The callback will get executed with a receiver scope that has an onDispose method which can be used to schedule a callback to schedule code that cleans up the code in the callback.

Parameters
v1: V1 An input value which will be compared across compositions to determine if callback will get executed.
v2: V2 An input value which will be compared across compositions to determine if callback will get executed.
callback: CommitScope.() -> Unit The lambda to be executed when the effect is committed to the composition.

onCommit

@Composable fun onCommit(
    vararg inputs: Any?,
    callback: CommitScope.() -> Unit
): Unit

The onCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed. It is useful for executing code in lock-step with composition that has side-effects that are based on the inputs. The callback will get executed with a receiver scope that has an onDispose method which can be used to schedule a callback to schedule code that cleans up the code in the callback.

Parameters
vararg inputs: Any? A set of inputs which will be compared across compositions to determine if callback will get executed.
callback: CommitScope.() -> Unit The lambda to be executed when the effect is committed to the composition.

onDispose

@Composable fun onDispose(callback: () -> Unit): Unit

An effect used to schedule work to be done when the effect leaves the composition.

The onDispose effect is essentially a convenience effect for onPreCommit(true) { onDispose { ... } }.

Parameters
callback: () -> Unit The lambda to be executed when the effect leaves the composition.

onPreCommit

@Composable inline fun onPreCommit(noinline callback: CommitScope.() -> Unit): Unit

The onPreCommit effect is a lifecycle effect that will execute callback every time the composition commits, but before those changes have been reflected on the screen. It is useful for executing code that needs to update in response to a composition and it is critical that the previous results are never seen by the user. If it is not critical, onCommit is recommended instead. The callback will get executed with a receiver scope that has an onDispose method which can be used to schedule a callback to schedule code that cleans up the code in the callback.

Parameters
callback: CommitScope.() -> Unit The lambda to be executed when the effect is committed to the composition.

onPreCommit

@Composable fun <V1> onPreCommit(
    v1: V1,
    callback: CommitScope.() -> Unit
): Unit

The onPreCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed, but before those changes have been reflected on the screen. It is useful for executing code that needs to update in response to a composition and it is critical that the previous results are never seen by the user. If it is not critical, onCommit is recommended instead. The callback will get executed with a receiver scope that has an onDispose method which can be used to schedule a callback to schedule code that cleans up the code in the callback.

Parameters
v1: V1 The input which will be compared across compositions to determine if callback will get executed.
callback: CommitScope.() -> Unit The lambda to be executed when the effect is committed to the composition.

onPreCommit

@Composable fun <V1, V2> onPreCommit(
    v1: V1,
    v2: V2,
    callback: CommitScope.() -> Unit
): Unit

The onPreCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed, but before those changes have been reflected on the screen. It is useful for executing code that needs to update in response to a composition and it is critical that the previous results are never seen by the user. If it is not critical, onCommit is recommended instead. The callback will get executed with a receiver scope that has an onDispose method which can be used to schedule a callback to schedule code that cleans up the code in the callback.

Parameters
v1: V1 An input value which will be compared across compositions to determine if callback will get executed.
v2: V2 An input value which will be compared across compositions to determine if callback will get executed.
callback: CommitScope.() -> Unit The lambda to be executed when the effect is committed to the composition.

onPreCommit

@Composable fun onPreCommit(
    vararg inputs: Any?,
    callback: CommitScope.() -> Unit
): Unit

The onPreCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed, but before those changes have been reflected on the screen. It is useful for executing code that needs to update in response to a composition and it is critical that the previous results are never seen by the user. If it is not critical, onCommit is recommended instead. The callback will get executed with a receiver scope that has an onDispose method which can be used to schedule a callback to schedule code that cleans up the code in the callback.

Parameters
vararg inputs: Any? A set of inputs which will be compared across compositions to determine if callback will get executed.
callback: CommitScope.() -> Unit The lambda to be executed when the effect is committed to the composition.

remember

@Composable inline fun <T> remember(calculation: () -> T): T

Remember the value produced by calculation. calculation will only be evaluated during the composition. Recomposition will always return the value produced by composition.

remember

@Composable inline fun <T, V1> remember(
    v1: V1,
    calculation: () -> T
): T

Remember the value returned by calculation if v1 is equal to the previous composition, otherwise produce and remember a new value by calling calculation.

remember

@Composable inline fun <T, V1, V2> remember(
    v1: V1,
    v2: V2,
    calculation: () -> T
): T

Remember the value returned by calculation if v1 and v2 are equal to the previous composition, otherwise produce and remember a new value by calling calculation.

remember

@Composable inline fun <T, V1, V2, V3> remember(
    v1: V1,
    v2: V2,
    v3: V3,
    calculation: () -> T
): T

Remember the value returned by calculation if v1, v2 and v3 are equal to the previous composition, otherwise produce and remember a new value by calling calculation.

remember

@Composable inline fun <V> remember(
    vararg inputs: Any?,
    block: () -> V
): V

Remember the value returned by block if all values of inputs are equal to the previous composition, otherwise produce and remember a new value by calling block.

state

@Composable inline fun <T> state(
    noinline areEquivalent: (old: T, new: T) -> Boolean = ReferentiallyEqual,
    init: () -> T
): MutableState<T>

A composable used to introduce a state value of type T into a composition.

This is useful when you have a value that you would like to locally mutate and use in the context of a composition. Since the returned MutableState instance implements Model, changes to the MutableState.value property will be automatically tracked in composition and schedule a recompose.

The MutableState class can be used several different ways. For example, the most basic way is to store the returned state value into a local immutable variable, and then set the MutableState.value property on it.


//Unresolved: androidx.compose.samples.SimpleStateSample
Additionally, you can destructure the MutableState object into a value and a "setter" function.

//Unresolved: androidx.compose.samples.DestructuredStateSample
Finally, the MutableState instance can be used as a variable delegate to a local mutable variable.

//Unresolved: androidx.compose.samples.DelegatedStateSample
Parameters
areEquivalent: (old: T, new: T) -> Boolean = ReferentiallyEqual a callback to compare the previous and new instance of T when MutableState.value is written to. If this returns true, then no recomposition will be scheduled. See ReferentiallyEqual and StructurallyEqual for simple implementations.
init: () -> T A factory function to create the initial value of this state
Return
An Model instance of MutableState that wraps the value.

See Also

stateFor

@Composable inline fun <T, V1> stateFor(
    v1: V1,
    init: () -> T
): MutableState<T>

An effect to introduce a state value of type T into a composition that will last as long as the input v1 does not change.

This is useful when you have a value that you would like to locally mutate and use in the context of a composition, and its value is scoped to another value and you want it to be reset every time the other value changes.

The returned MutableState instance implements Model so that changes to the MutableState.value property will be automatically tracked in composition and schedule a recompose.


//Unresolved: androidx.compose.samples.observeUserSample
Parameters
v1: V1 An input value that, when changed, will cause the state to reset and init to be rerun
init: () -> T A factory function to create the initial value of this state
Return
An Model instance of MutableState that wraps the value.

See Also

stateFor

@Composable inline fun <T, reified V1, reified V2> stateFor(
    v1: V1,
    v2: V2,
    init: () -> T
): MutableState<T>

An effect to introduce a state value of type T into a composition that will last as long as the inputs v1 and v2 do not change.

This is useful when you have a value that you would like to locally mutate and use in the context of a composition, and its value is scoped to another value and you want it to be reset every time the other value changes.

The returned MutableState instance implements Model so that changes to the MutableState.value property will be automatically tracked in composition and schedule a recompose.

Parameters
v1: V1 An input value that, when changed, will cause the state to reset and init to be rerun
v2: V2 An input value that, when changed, will cause the state to reset and init to be rerun
init: () -> T A factory function to create the initial value of this state
Return
An Model instance of MutableState that wraps the value.

See Also

stateFor

@Composable inline fun <T> stateFor(
    vararg inputs: Any?,
    init: () -> T
): MutableState<T>

An effect to introduce a state value of type T into a composition that will last as long as the inputs inputs do not change.

This is useful when you have a value that you would like to locally mutate and use in the context of a composition, and its value is scoped to another value and you want it to be reset every time the other value changes.

The returned MutableState instance implements Model so that changes to the MutableState.value property will be automatically tracked in composition and schedule a recompose.

Parameters
vararg inputs: Any? A set of inputs such that, when any of them have changed, will cause the state to reset and init to be rerun
init: () -> T A factory function to create the initial value of this state
Return
An Model instance of MutableState that wraps the value.

See Also

staticAmbientOf

fun <T> staticAmbientOf(defaultFactory: () -> T = null): ProvidableAmbient<T>

Create an ambient key that can be provided using Providers. Changing the value provided will cause the entire tree below Providers to be recomposed, disabling skipping of composable calls.

A static ambient should be only be used when the value provided is highly unlikely to change.

See Also

Top-level properties

NeverEqual

val NeverEqual: (Any?, Any?) -> Boolean

Simple comparison callback that always returns false, for mutable objects that will be compared with the same reference.

In this case we cannot correctly compare for equality, and so we trust that something else correctly triggered a recomposition.

ReferentiallyEqual

val ReferentiallyEqual: (Any?, Any?) -> Boolean

Simple comparison callback using referential === equality

StructurallyEqual

val StructurallyEqual: (Any?, Any?) -> Boolean

Simple comparison callback using structural Any.equals equality

composer

val composer: UiComposer

Deprecated.

currentComposer

@Composable val currentComposer: Composer<*>

invalidate

@Composable val invalidate: () -> Unit

An Effect to get the nearest invalidation lambda to the current point of composition. This can be used to trigger an invalidation on the composition locally to cause a recompose.

Extension functions

cache

inline fun <N, T> Composer<N>.cache(
    valid: Boolean = true,
    block: () -> T
): T

Cache a value in the composition. During initial composition block is called to produce the value that is then * stored in the slot table. During recomposition, if valid is true the value is obtained from the slot table and block is not invoked. If valid is false a new value is produced by calling block and the slot table is updated to contain the new value.

nextValue

fun <N> Composer<N>.nextValue(): Any?

Get the next value of the slot table. This will unwrap lifecycle observer holders to return lifecycle observer and should be used instead of Composer.nextSlot.

orEmpty

inline fun (() -> Unit).orEmpty(): () -> Unit
Return
this Composable if not null, else emptyContent.