Module: Bowline::Desktop::JS

Defined in:
lib/bowline/desktop/js.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Script

Class Method Summary collapse

Class Method Details

.eval(window, string, method = nil, &block) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/bowline/desktop/js.rb', line 64

def eval(window, string, method = nil, &block)
  script = Script.new(window, string, method||block)
  if Runtime.main_thread? && script.ready?
    script.call
  else
    scripts << script
  end
end

.pollObject



75
76
77
78
79
80
81
# File 'lib/bowline/desktop/js.rb', line 75

def poll
  ready_scripts = scripts.select(&:ready?)
  ready_scripts.each do |script|
    script.call
    scripts.delete(script)
  end
end

.scriptsObject



84
85
86
# File 'lib/bowline/desktop/js.rb', line 84

def scripts
  @scripts ||= []
end

.setup!Object

:nodoc:



59
60
61
# File 'lib/bowline/desktop/js.rb', line 59

def setup! #:nodoc:
  Desktop.on_idle(method(:poll))
end