Module: Kernel

Defined in:
lib/reactive_record/interval.rb,
lib/reactive_record/interval.rb

Instance Method Summary collapse

Instance Method Details

#after(time, &block) ⇒ Delay

Execute a block after the given seconds.

Parameters:

  • time (Float)

    the seconds after it gets called

Returns:

  • (Delay)

    the object representing the timeout



170
171
172
# File 'lib/reactive_record/interval.rb', line 170

def after(time, &block)
  `setTimeout(#{block.to_n}, time * 1000)`
end

#after!(time, &block) ⇒ Delay

Execute a block after the given seconds, you have to call [#start] on it yourself.

Parameters:

  • time (Float)

    the seconds after it gets called

Returns:

  • (Delay)

    the object representing the timeout



175
176
177
# File 'lib/reactive_record/interval.rb', line 175

def after!(time, &block)
  `setTimeout(#{block.to_n}, time * 1000)`
end

#every(time, &block) ⇒ Interval

Execute the block every given seconds.

Parameters:

  • time (Float)

    the seconds between every call

Returns:

  • (Interval)

    the object representing the interval



91
92
93
# File 'lib/reactive_record/interval.rb', line 91

def every(time, &block)
  $window.every(time, &block)
end

#every!(time, &block) ⇒ Interval

Execute the block every given seconds, you have to call [#start] on it yourself.

Parameters:

  • time (Float)

    the seconds between every call

Returns:

  • (Interval)

    the object representing the interval



96
97
98
# File 'lib/reactive_record/interval.rb', line 96

def every!(time, &block)
  $window.every!(time, &block)
end