Class: TRMNLP::App

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/trmnlp/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
34
35
36
# File 'lib/trmnlp/app.rb', line 15

def initialize(*args)
  super

  @context = settings.context

  @context.poll_data

  @context.start_filewatcher if @context.config.project.live_render?

  @live_reload_clients = []
  @context.on_view_change do |view, user_data|
    @live_reload_clients.each do |ws|
      payload = {
        'type' => 'reload',
        'view' => view,
        'user_data' => user_data
      }

      ws.send(payload.to_json)
    end
  end
end