Module: ActionView::Component::Live::Subscriber

Extended by:
ActiveSupport::Concern
Defined in:
app/models/action_view/component/live/subscriber.rb

Instance Method Summary collapse

Instance Method Details

#liveObject

Used as view helper to wrap view in div that will connect to auto-updating stimulus controller If we render the component in live update on cable we will not wrap it - we just need the component content.



24
25
26
27
28
# File 'app/models/action_view/component/live/subscriber.rb', line 24

def live
  return yield if live_render?
  # <div data-controller="live" data-live-component="UserCardComponent" data-live-id="<%= id %>">
  (:div, nil, data: {controller: :live, live_component: self.class.name, live_id: id}) { yield }
end

#live_render!Object



7
8
9
# File 'app/models/action_view/component/live/subscriber.rb', line 7

def live_render!
  @live_render = true
end

#live_render?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'app/models/action_view/component/live/subscriber.rb', line 11

def live_render?
  @live_render
end