GuiProperty

class GuiProperty<T>(value: T)(source)

A property which can be used to represent mutable state in a gui. You can use the net.silkmc.silk.igui.guiIcon function to specify how the value of this property can be rendered to the gui.

Constructors

Link copied to clipboard
constructor(value: T)

Functions

Link copied to clipboard
suspend fun get(): T

Gets the current value of the property. This function is thread-safe.

Link copied to clipboard
fun <E> GuiProperty<E>.guiIcon(iconGenerator: (E) -> ItemStack): GuiIcon.VariableIcon<E>

Creates a gui icon which automatically updates itself if the value of the property changes.

Link copied to clipboard
fun invokeListeners(): Job

Invokes all listeners, causing all open guis using this list to update.

Link copied to clipboard
fun onChange(block: suspend (T) -> Unit)

Registers a new onChange listener, which will be called if the value of this property is updated.

Link copied to clipboard
fun removeOnChangeListener(block: suspend (T) -> Unit)

Unregisters an already registered onChangeListener.

Link copied to clipboard
suspend fun set(value: T): Job

Sets the value of this property, this will cause all guis which are currently displaying a net.silkmc.silk.igui.GuiIcon using this property to update. This function is thread-safe.