Class: ViewComponentDevtools::Subscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/view_component_devtools/subscriber.rb

Constant Summary collapse

EVENT_NAMES =
["render.view_component", "!render.view_component"].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.install!Object



10
11
12
13
14
15
16
17
# File 'lib/view_component_devtools/subscriber.rb', line 10

def install!
  @install_mutex ||= Mutex.new
  @install_mutex.synchronize do
    @subscriptions ||= EVENT_NAMES.map do |event_name|
      ActiveSupport::Notifications.subscribe(event_name, new)
    end
  end
end

Instance Method Details

#finish(_name, event_id, payload) ⇒ Object



24
25
26
# File 'lib/view_component_devtools/subscriber.rb', line 24

def finish(_name, event_id, payload)
  State.current&.finish_event(event_id, payload, monotonic_time)
end

#start(_name, event_id, payload) ⇒ Object



20
21
22
# File 'lib/view_component_devtools/subscriber.rb', line 20

def start(_name, event_id, payload)
  State.current&.start_event(event_id, payload, monotonic_time)
end