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.
125 126 127 128 |
# File 'lib/dommy/bridge.rb', line 125 def initialize(promise, fulfilled:) @promise = promise @fulfilled = fulfilled end |
Instance Method Details
#__js_call__(_method, args) ⇒ Object
130 131 132 133 134 135 136 137 138 |
# File 'lib/dommy/bridge.rb', line 130 def __js_call__(_method, args) if @fulfilled @promise.fulfill(args[0]) else @promise.reject(args[0]) end nil end |