Class: Browser::Delay
Overview
Allows you to delay the call to a function which gets called after the given time.
Instance Attribute Summary collapse
-
#after ⇒ Float
readonly
The seconds after which the block is called.
Instance Method Summary collapse
-
#abort ⇒ Object
Abort the timeout.
-
#initialize(window, time, &block) ⇒ Delay
constructor
Create and start a timeout.
-
#start ⇒ Object
Start the delay.
Constructor Details
#initialize(window, time, &block) ⇒ Delay
Create and start a timeout.
128 129 130 131 132 |
# File 'lib/reactive_record/interval.rb', line 128 def initialize(window, time, &block) @window = Native.convert(window) @after = time @block = block end |
Instance Attribute Details
#after ⇒ Float (readonly)
Returns the seconds after which the block is called.
122 123 124 |
# File 'lib/reactive_record/interval.rb', line 122 def after @after end |
Instance Method Details
#abort ⇒ Object
Abort the timeout.
135 136 137 |
# File 'lib/reactive_record/interval.rb', line 135 def abort `#@window.clearTimeout(#@id)` end |
#start ⇒ Object
Start the delay.
140 141 142 |
# File 'lib/reactive_record/interval.rb', line 140 def start @id = `#@window.setTimeout(#{@block.to_n}, #@after * 1000)` end |