Module: Ione::Future::Callbacks
- Included in:
- Ione::Future
- Defined in:
- lib/ione/future.rb
Overview
Instance Method Summary collapse
-
#on_failure {|error| ... } ⇒ Object
Registers a listener that will be called when this future fails.
-
#on_value {|value| ... } ⇒ Object
Registers a listener that will be called when this future becomes resolved.
Instance Method Details
#on_failure {|error| ... } ⇒ Object
Registers a listener that will be called when this future fails. The lisener will be called with the error that failed the future as sole argument.
585 586 587 588 589 590 |
# File 'lib/ione/future.rb', line 585 def on_failure(&listener) on_complete do |_, error| listener.call(error) if error end nil end |
#on_value {|value| ... } ⇒ Object
Registers a listener that will be called when this future becomes resolved. The listener will be called with the value of the future as sole argument.
573 574 575 576 577 578 |
# File 'lib/ione/future.rb', line 573 def on_value(&listener) on_complete do |value, error| listener.call(value) unless error end nil end |