ComposableContract

annotation class ComposableContract(restartable: Boolean, readonly: Boolean, tracked: Boolean, preventCapture: Boolean)

This annotation can be applied to Composable functions and provide metadata to the compiler that imply compose-specific contracts that the author of the function is guaranteeing the function complies with. This metadata can be used to generate more efficient code.

Caution: Use of this annotation means that the annotated declaration MUST comply with those contracts, or else the resulting code's behavior will be undefined.

Parameters

preventCapture

if true, this will prevent composable calls from happening inside of the function that it applies to. This is usually applied to lambda parameters of inline functions that ought to be safely inlined but cannot safely have composable calls in them

readonly

if true, no group will be generated around the body of the function it annotates . This is not safe unless the body of the function only executes "read" operations on the passed in composer..

restartable

if false, this will prevent code from being generated which allow this function's execution to be skipped or restarted. This may be desirable for small functions which just directly call another composable function and have very little machinery in them directly.

tracked

if false, this will disable lambda optimizations such as tracking execution of composable function expressions or remembering a function expression value based on its capture variables. This flag is only meaningful when applied to @Composable lambda expressions

Constructors

ComposableContract
Link copied to clipboard
common
fun ComposableContract(restartable: Boolean = true, readonly: Boolean = false, tracked: Boolean = true, preventCapture: Boolean = false)
if false, this will prevent code from being generated which allow this function's execution to be skipped or restarted.

Functions

equals
Link copied to clipboard
common
open operator fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
common
open fun hashCode(): Int
toString
Link copied to clipboard
common
open fun toString(): String

Properties

preventCapture
Link copied to clipboard
common
val preventCapture: Boolean = false
if true, this will prevent composable calls from happening inside of the function that it applies to.
readonly
Link copied to clipboard
common
val readonly: Boolean = false
if true, no group will be generated around the body of the function it annotates .
restartable
Link copied to clipboard
common
val restartable: Boolean = true
if false, this will prevent code from being generated which allow this function's execution to be skipped or restarted.
tracked
Link copied to clipboard
common
val tracked: Boolean = true
if false, this will disable lambda optimizations such as tracking execution of composable function expressions or remembering a function expression value based on its capture variables.