Class: Browser::Immediate
Overview
Class to easily create and dispatch an immediate call.
Immediate calls are deferred function calls that happen as soon as they can be scheduled.
Compatibility
The compatibility layer will try various implementations in the following order.
The order has been chosen from best to worst for both performance and preemptiveness.
Instance Method Summary collapse
-
#abort ⇒ Object
Abort the immediate.
-
#aborted? ⇒ Boolean
Check if the immediate has been aborted.
-
#dispatch ⇒ Object
Dispatch the immediate.
-
#initialize(func, args, &block) ⇒ Immediate
constructor
Create an immediate for the given function which will be called with the arguments and block.
- #prevent ⇒ Object
Constructor Details
#initialize(func, args, &block) ⇒ Immediate
Create an immediate for the given function which will be called with the arguments and block.
26 27 28 29 30 31 |
# File 'opal/browser/immediate.rb', line 26 def initialize(func, args, &block) @aborted = false @function = func @arguments = args @block = block end |
Instance Method Details
#abort ⇒ Object
Abort the immediate.
115 116 117 118 119 120 121 122 |
# File 'opal/browser/immediate.rb', line 115 def abort return if aborted? @aborted = true prevent self end |
#aborted? ⇒ Boolean
Check if the immediate has been aborted.
125 126 127 |
# File 'opal/browser/immediate.rb', line 125 def aborted? @aborted end |
#prevent ⇒ Object
45 46 47 |
# File 'opal/browser/immediate.rb', line 45 def prevent `window.clearImmediate(#@id)` end |