class Browser::Delay

Allows you to delay the call to a function which gets called after the given time.

@see developer.mozilla.org/en-US/docs/Web/API/Window.setTimeout

Attributes

after[R]

@!attribute [r] after @return [Float] the seconds after which the block is called

Public Class Methods

new(window, time, &block) click to toggle source

Create and start a timeout.

@param window [Window] the window to start the timeout on @param time [Float] seconds after which the block is called

# File lib/reactive_record/interval.rb, line 128
def initialize(window, time, &block)
  @window = Native.convert(window)
  @after  = time
  @block  = block
end

Public Instance Methods

abort() click to toggle source

Abort the timeout.

# File lib/reactive_record/interval.rb, line 135
def abort
  `#@window.clearTimeout(#@id)`
end
start() click to toggle source

Start the delay.

# File lib/reactive_record/interval.rb, line 140
def start
  @id = `#@window.setTimeout(#{@block.to_n}, #@after * 1000)`
end