Class: Bridgetown::Rack::LiveReload

Inherits:
Object
  • Object
show all
Defined in:
lib/bridgetown-core/rack/live_reload.rb

Constant Summary collapse

SLEEP_INTERVAL =
0.5

Instance Method Summary collapse

Constructor Details

#initialize(file_to_check:, errors_file:) ⇒ LiveReload

Returns a new instance of LiveReload.



9
10
11
12
13
14
# File 'lib/bridgetown-core/rack/live_reload.rb', line 9

def initialize(file_to_check:, errors_file:)
  @file_to_check = file_to_check
  @errors_file = errors_file

  @last_modified = self.current_modified
end

Instance Method Details

#event_streamObject



16
17
18
19
20
21
22
23
24
# File 'lib/bridgetown-core/rack/live_reload.rb', line 16

def event_stream
  proc do |stream|
    begin
      run_loop(stream)
    ensure
      stream.close
    end
  end
end

#threaded_event_streamObject



26
27
28
29
30
31
32
33
34
# File 'lib/bridgetown-core/rack/live_reload.rb', line 26

def threaded_event_stream
  proc do |stream|
    Thread.new do
      run_loop(stream)
    ensure
      stream.close
    end
  end
end