Class: TRMNLPreview::App

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/trmnl_preview/app.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ App

Returns a new instance of App.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/trmnl_preview/app.rb', line 15

def initialize(*args)
  super

  begin
    @context = Context.new(settings.user_dir)
  rescue StandardError => e
    puts e.message
    exit 1
  end

  @context.poll_data if @context.strategy == 'polling'

  @live_reload_clients = []
  @context.on_view_change do |view|
    @live_reload_clients.each do |ws|
      ws.send('reload')
    end
  end
end