Class: Fron::RenderProc
Overview
Render Proc for rendering efficiently, it uses requestAnimationFrame to limit the number of cycles.
Instance Method Summary collapse
-
#call ⇒ Object
Runs the proc.
-
#initialize(method, verbose, message) ⇒ RenderProc
constructor
Initializes a render proc.
Constructor Details
#initialize(method, verbose, message) ⇒ RenderProc
Initializes a render proc
9 10 11 12 13 14 |
# File 'opal/fron/utils/render_proc.rb', line 9 def initialize(method, verbose, ) @running = false @method = method @verbose = verbose @message = end |
Instance Method Details
#call ⇒ Object
Runs the proc
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'opal/fron/utils/render_proc.rb', line 17 def call return if @running @running = true request_animation_frame do time = Time.now @method.call if @verbose = @message || "Rendered #{@method.owner}" logger.info "[#{(Time.now - time) * 1000}ms] #{}" end @running = false end end |