State

class State<T> : Value<T>

Interface with which a component gets the value from a state or updates it.

Properties

Link copied to clipboard
open override val value: T

The current value.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

We consider two state objects equal if they 1) belong to the same Tree, 2) have the same HookGlobalKey, and 3) have the same value (according to its own .equals check)

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun update(newValue: T)

Updates this state value and enqueues a new layout calculation reflecting it to execute in the background.

fun update(newValueFunction: (T) -> T)

Uses newValueFunction to update this state value using the previous state value, and enqueues a new layout calculation reflecting it to execute in the background.

Link copied to clipboard
fun updateSync(newValue: T)

Updates this state value and enqueues a new layout calculation reflecting it to execute on the current thread. If called on the main thread, this means that the UI will be updated for the current frame.

fun updateSync(newValueFunction: (T) -> T)

Uses newValueFunction to update this state value using the previous state value, and enqueues a new layout calculation reflecting it to execute on the current thread.