Class: DrawCycle
Overview
The draw cycle is responsible for queueing redraws until all of the events have fired. Once that is done, everything will be redrawn. This prevents bindings from being drawn multiple times before all events have propigated.
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize ⇒ DrawCycle
constructor
A new instance of DrawCycle.
- #queue(binding) ⇒ Object
Constructor Details
#initialize ⇒ DrawCycle
Returns a new instance of DrawCycle.
5 6 7 8 |
# File 'lib/volt/page/draw_cycle.rb', line 5 def initialize @queue = {} @timer = nil end |
Instance Method Details
#flush ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/volt/page/draw_cycle.rb', line 19 def flush @timer = nil work_queue = @queue @queue = {} work_queue.each_pair do |binding,_| # Call the update if queued binding.update end end |
#queue(binding) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/volt/page/draw_cycle.rb', line 10 def queue(binding) @queue[binding] = true unless @timer # Flush once everything else has finished running @timer = `setTimeout(function() { self.$flush(); }, 0);` end end |