Skip to content

observeItemProperty

@Composable



inline fun <T> observeItemProperty(propertyName: String, initialValue: T? = null): MutableState<T?>

Observes a property on the current ComposeItemContainerMenu in the current composition context. The net.kernelpanicsoft.archie.gui.blockentity.observeProperty equivalent for item-backed menus.

Returns a MutableState that automatically triggers recomposition when the property changes. Must be called where LocalItemState has been provided with a non-null value (i.e. inside an item-backed menu's screen composition) - otherwise it throws.

Example

@Composable
fun MyComponent() {
    val progressState = observeItemProperty<Int>("progress")
    Text("Progress: ${progressState.value}")
}

Return

A MutableState of type T reflecting the property's current value.

Parameters

  • propertyName: The name of the property to observe.

  • T: The expected type of the property.

Throws

RuntimeException

if no ComposeItemState is available in the current composition.