class
UI::State(T)
- UI::State(T)
- Reference
- Object
Overview
Type-safe reactive state container.
When the value changes, all registered listeners are notified with
the old and new values. Listeners are NOT called when the same
value is assigned (equality check via !=).
Example: counter = UI::State(Int32).new(0) counter.on_change { |old_val, new_val| puts "#{old_val} -> #{new_val}" } counter.value = 1 # prints "0 -> 1" counter.value = 1 # no output (same value)
Defined in:
ui/state.crConstructors
Instance Method Summary
- #on_change(&block : T, T -> Nil) : Nil
- #remove_listeners : Nil
- #value : T
- #value=(new_value : T) : T