Module: Glimmer::LibUI::DataBindable
- Included in:
- AttributedString, ControlProxy, Shape
- Defined in:
- lib/glimmer/libui/data_bindable.rb
Overview
Parent controls and shapes who have children and add child post_initialize_child
Instance Method Summary collapse
-
#data_bind(property, model_binding) ⇒ Object
Data-binds model to update view.
Instance Method Details
#data_bind(property, model_binding) ⇒ Object
Data-binds model to update view. Subclasses can override to do inverse data-binding by observing view control for property changes and updating model binding accordingly
28 29 30 31 32 33 34 35 36 |
# File 'lib/glimmer/libui/data_bindable.rb', line 28 def data_bind(property, model_binding) model_attribute_observer = Glimmer::DataBinding::Observer.proc do new_value = model_binding.evaluate_property send("#{property}=", new_value) unless send(property) == new_value end model_attribute_observer.observe(model_binding) model_attribute_observer.call # initial update model_attribute_observer end |