Class: DuoRuby::ReplyPromise
- Inherits:
-
Async::Promise
- Object
- Async::Promise
- DuoRuby::ReplyPromise
- Defined in:
- lib/duoruby/reply_promise.rb
Overview
Async-backed server-side reply promise.
It keeps Async::Promise’s native #wait API and adds the small PromiseV2-like surface DuoRuby exposes across runtimes.
Instance Method Summary collapse
- #await ⇒ Object (also: #__await__)
- #fail(&handler) ⇒ Object (also: #rescue)
- #then(&handler) ⇒ Object
Instance Method Details
#await ⇒ Object Also known as: __await__
13 14 15 |
# File 'lib/duoruby/reply_promise.rb', line 13 def await(...) wait(...) end |
#fail(&handler) ⇒ Object Also known as: rescue
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/duoruby/reply_promise.rb', line 31 def fail(&handler) return self unless handler if resolved? call_failure(handler) else schedule { call_failure(handler) } end self end |
#then(&handler) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/duoruby/reply_promise.rb', line 19 def then(&handler) return self unless handler if resolved? handler.call(wait) if completed? else schedule { call_success(handler) } end self end |