Module: LiveCable::Connection::ComponentManagement

Extended by:
ActiveSupport::Concern
Included in:
LiveCable::Connection
Defined in:
lib/live_cable/connection/component_management.rb

Instance Method Summary collapse

Instance Method Details

#add_component(component) ⇒ Object



12
13
14
15
# File 'lib/live_cable/connection/component_management.rb', line 12

def add_component(component)
  component.live_connection = self
  components[component.live_id] = component
end

#get_component(id) ⇒ Object



8
9
10
# File 'lib/live_cable/connection/component_management.rb', line 8

def get_component(id)
  components[id]
end

#remove_component(component) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/live_cable/connection/component_management.rb', line 17

def remove_component(component)
  # Clean up the container to break observer reference chains
  container = containers.delete(component.live_id)
  container&.cleanup

  components.delete(component.live_id)

  # Clean up shared container if no components remain
  cleanup_shared_container
end