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.
580 581 582 583 584 585 |
# File 'lib/ione/future.rb', line 580 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.
568 569 570 571 572 573 |
# File 'lib/ione/future.rb', line 568 def on_value(&listener) on_complete do |value, error| listener.call(value) unless error end nil end |