Module: Glimmer::LibUI::ContentBindable
- Included in:
- ControlProxy, Shape
- Defined in:
- lib/glimmer/libui/content_bindable.rb
Instance Method Summary collapse
-
#bind_content(*binding_args, &content_block) ⇒ Object
Data-binds the generation of nested content to a model/property (in binding args) consider providing an option to avoid initial rendering without any changes happening.
Instance Method Details
#bind_content(*binding_args, &content_block) ⇒ Object
Data-binds the generation of nested content to a model/property (in binding args) consider providing an option to avoid initial rendering without any changes happening
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/glimmer/libui/content_bindable.rb', line 6 def bind_content(*binding_args, &content_block) # TODO in the future, consider optimizing code by diffing content if that makes sense content_binding_work = proc do |*values| children.dup.each { |child| child.destroy } content(&content_block) end model_binding_observer = Glimmer::DataBinding::ModelBinding.new(*binding_args) content_binding_observer = Glimmer::DataBinding::Observer.proc(&content_binding_work) content_binding_observer.observe(model_binding_observer) content_binding_work.call # TODO inspect if we need to pass args here (from observed attributes) [but it's simpler not to pass anything at first] end |