Class: TurboLive::Component

Inherits:
Phlex::HTML
  • Object
show all
Extended by:
Literal::Properties
Defined in:
lib/turbo_live/component.rb

Constant Summary collapse

SUPPORTED_EVENTS =
i[click change input].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.state(name, type, **options, &block) ⇒ Object



12
13
14
15
# File 'lib/turbo_live/component.rb', line 12

def self.state(name, type, **options, &block)
  options = {reader: :public, writer: :protected}.merge(**options).compact
  prop(name, _Nilable(type), **options, &block)
end

Instance Method Details

#update(input) ⇒ Object



33
34
# File 'lib/turbo_live/component.rb', line 33

def update(input)
end

#verifiable_live_idObject



36
37
38
# File 'lib/turbo_live/component.rb', line 36

def verifiable_live_id
  to_verifiable(live_id)
end

#view_templateObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/turbo_live/component.rb', line 21

def view_template
  div(
    id: verifiable_live_id,
    style: "display: contents;",
    data_controller: "turbo-live",
    data_turbo_live_component_value: to_verifiable(serialize),
    data_turbo_live_protocol_version_value: TurboLive::PROTOCOL_VERSION
  ) do
    view
  end
end