Class: Dommy::Bridge::PromiseSettler
- Inherits:
-
Object
- Object
- Dommy::Bridge::PromiseSettler
- Defined in:
- lib/dommy/bridge.rb
Overview
Adapter so a Ruby-side executor can deliver resolve/reject
through the same __js_call__("call", args) interface that
the scheduler and JS bridge use for callbacks.
Instance Method Summary collapse
- #__js_call__(_method, args) ⇒ Object
-
#initialize(promise, fulfilled:) ⇒ PromiseSettler
constructor
A new instance of PromiseSettler.
Constructor Details
#initialize(promise, fulfilled:) ⇒ PromiseSettler
Returns a new instance of PromiseSettler.
233 234 235 236 |
# File 'lib/dommy/bridge.rb', line 233 def initialize(promise, fulfilled:) @promise = promise @fulfilled = fulfilled end |
Instance Method Details
#__js_call__(_method, args) ⇒ Object
238 239 240 241 242 243 244 245 246 |
# File 'lib/dommy/bridge.rb', line 238 def __js_call__(_method, args) if @fulfilled @promise.fulfill(args[0]) else @promise.reject(args[0]) end nil end |