Module: LiveCable::Connection::Broadcasting
- Extended by:
- ActiveSupport::Concern
- Included in:
- LiveCable::Connection
- Defined in:
- lib/live_cable/connection/broadcasting.rb
Instance Method Summary collapse
-
#broadcast_changeset ⇒ Array<LiveCable::Component>
Components that were broadcast to (rendered or errored), including children rendered by their parents.
Instance Method Details
#broadcast_changeset ⇒ Array<LiveCable::Component>
Returns Components that were broadcast to (rendered or errored), including children rendered by their parents.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/live_cable/connection/broadcasting.rb', line 10 def broadcast_changeset rendered = [] shared_changeset = containers[SHARED_CONTAINER]&.changeset # Use a copy of the components since new ones can get added while rendering # and causes an issue here. components.values.dup.each do |component| # Component may have already been re-rendered by a parent, so don't render it again next if rendered.include?(component) container = containers[component.live_id] next unless container&.changed? || component.shared_reactive_variables.intersect?(shared_changeset) begin component.broadcast_render rescue StandardError => error handle_error(component, error) end rendered |= [component] | component.rendered_children end # Deliver events from components that didn't broadcast a render this # cycle (no state change, or rendered inline by a parent) - rendered # components already flushed their events with the refresh components.each_value do |component| events = component.flush_events component.broadcast(_events: events) if events.any? end rendered end |