State

class State<T>

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

Types

Link copied to clipboard
inner class HookUpdaterLambda(val newValueFunction: (T) -> T) : HookUpdater
Link copied to clipboard
inner class HookUpdaterValue(val newValue: T) : HookUpdater

Properties

Link copied to clipboard
val value: T

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 global key and hook index, 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.