Class: Phlex::Reactive::Component::CollectionDefinition
- Inherits:
-
Data
- Object
- Data
- Phlex::Reactive::Component::CollectionDefinition
- Defined in:
- lib/phlex/reactive/component.rb
Overview
A declared add/remove-row collection (issue #35): the list contract tied into one unit — the per-row item component, the container DOM id rows live in, an optional companion count id, an optional empty-state component, and a size resolver (a proc evaluated against the container instance) used to re-render the count and toggle the empty-state at the 0<->1 boundary. count/empty/size are nil when not declared, and the corresponding stream is simply omitted — so a list with just rows still works.
Instance Attribute Summary collapse
-
#container ⇒ Object
readonly
Returns the value of attribute container.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#empty ⇒ Object
readonly
Returns the value of attribute empty.
-
#item ⇒ Object
readonly
Returns the value of attribute item.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
-
#size_for(component) ⇒ Object
The collection's current size, evaluated against the bound container instance (instance_exec so the proc reads the component's ivars / association).
Instance Attribute Details
#container ⇒ Object (readonly)
Returns the value of attribute container
73 74 75 |
# File 'lib/phlex/reactive/component.rb', line 73 def container @container end |
#count ⇒ Object (readonly)
Returns the value of attribute count
73 74 75 |
# File 'lib/phlex/reactive/component.rb', line 73 def count @count end |
#empty ⇒ Object (readonly)
Returns the value of attribute empty
73 74 75 |
# File 'lib/phlex/reactive/component.rb', line 73 def empty @empty end |
#item ⇒ Object (readonly)
Returns the value of attribute item
73 74 75 |
# File 'lib/phlex/reactive/component.rb', line 73 def item @item end |
#name ⇒ Object (readonly)
Returns the value of attribute name
73 74 75 |
# File 'lib/phlex/reactive/component.rb', line 73 def name @name end |
#size ⇒ Object (readonly)
Returns the value of attribute size
73 74 75 |
# File 'lib/phlex/reactive/component.rb', line 73 def size @size end |
Instance Method Details
#size_for(component) ⇒ Object
The collection's current size, evaluated against the bound container instance (instance_exec so the proc reads the component's ivars / association). nil when no resolver was declared — callers skip the count/empty streams that need a number.
78 79 80 |
# File 'lib/phlex/reactive/component.rb', line 78 def size_for(component) size && component.instance_exec(&size) end |