跳转至

Data Binding

UIFlow provides two binding tools: UIFlowBindUtils and convenience methods on UIFlowPage. Bindings are automatically cleaned up when a page closes.

Property Binding

Sync a property from a data object to a UI control:

func _on_opened(_data: Dictionary) -> void:
    bind_property(player_data, "health", health_bar, "value")
    bind_property(player_data, "name", name_label, "text")

Signal Binding

Call a method when a signal fires:

bind_signal(player_data.health_changed, _on_health_changed)

List Binding

Bind an array signal to a template node. Items are created, updated, and destroyed automatically:

var list_binder := UIFlowListBinder.new()
list_binder.bind(
    inventory.items,
    item_container,
    preload("res://UIScene/ItemRow.tscn"),
    _setup_item
)

func _setup_item(item: ItemData, node: Control) -> void:
    node.get_node("Icon").texture = item.icon
    node.get_node("Name").text = item.name

Automatic Cleanup

UIFlowPage._unbind_all() is called automatically when a page closes, so you do not need to manage it manually.

Data Store

UIFlowDataStore provides a global key-value store for lightweight cross-page state:

UIFlow.DataStore.set_value("player_name", "Alice")
var name := UIFlow.DataStore.get_value("player_name", "")