Module: LiveCable::Connection::StateManagement
- Extended by:
- ActiveSupport::Concern
- Included in:
- LiveCable::Connection
- Defined in:
- lib/live_cable/connection/state_management.rb
Instance Method Summary collapse
- #changeset_for(component) ⇒ Object
- #dirty(container_name, *variables) ⇒ Object
- #get(container_name, component, variable, initial_value) ⇒ Object
- #reset_changeset ⇒ Object
- #set(container_name, variable, value) ⇒ Object
Instance Method Details
#changeset_for(component) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/live_cable/connection/state_management.rb', line 30 def changeset_for(component) shared_changeset = containers[SHARED_CONTAINER]&.changeset container = containers[component.live_id] container.changeset | component.shared_reactive_variables.intersection(shared_changeset) end |
#dirty(container_name, *variables) ⇒ Object
22 23 24 |
# File 'lib/live_cable/connection/state_management.rb', line 22 def dirty(container_name, *variables) containers[container_name].mark_dirty(*variables) end |
#get(container_name, component, variable, initial_value) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/live_cable/connection/state_management.rb', line 8 def get(container_name, component, variable, initial_value) container = containers[container_name] return container[variable] if container.key?(variable) container[variable] = process_initial_value(component, variable, initial_value) end |
#reset_changeset ⇒ Object
26 27 28 |
# File 'lib/live_cable/connection/state_management.rb', line 26 def reset_changeset containers.each_value(&:reset_changeset) end |
#set(container_name, variable, value) ⇒ Object
16 17 18 19 20 |
# File 'lib/live_cable/connection/state_management.rb', line 16 def set(container_name, variable, value) dirty(container_name, variable) containers[container_name][variable] = value end |