Class: Reacto::Subscriptions::InnerSubscription
- Inherits:
-
SimpleSubscription
- Object
- SimpleSubscription
- Reacto::Subscriptions::InnerSubscription
- Includes:
- Subscription
- Defined in:
- lib/reacto/subscriptions/inner_subscription.rb
Instance Attribute Summary collapse
-
#last_error ⇒ Object
Returns the value of attribute last_error.
-
#last_value ⇒ Object
Returns the value of attribute last_value.
Attributes inherited from SimpleSubscription
Instance Method Summary collapse
- #active? ⇒ Boolean
- #closed? ⇒ Boolean
-
#initialize(parent) ⇒ InnerSubscription
constructor
A new instance of InnerSubscription.
- #unsubscribe ⇒ Object
Methods included from Subscription
#add, #add_resource, #subscribed?
Methods inherited from SimpleSubscription
#add, #add_resource, #on_close, #on_error, #on_open, #on_value, #subscribed?
Constructor Details
#initialize(parent) ⇒ InnerSubscription
Returns a new instance of InnerSubscription.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/reacto/subscriptions/inner_subscription.rb', line 8 def initialize(parent) @parent = parent @closed = false @active = false @last_value = NO_VALUE @last_error = nil open = lambda do @active = true @parent.on_open end value = lambda do |v| @last_value = v @parent.on_value(v) end error = lambda do |e| @last_error = e @parent.on_error(e) end close = lambda do @closed = true @parent.on_close end super(open: open, value: value, error: error, close: close) end |
Instance Attribute Details
#last_error ⇒ Object
Returns the value of attribute last_error.
6 7 8 |
# File 'lib/reacto/subscriptions/inner_subscription.rb', line 6 def last_error @last_error end |
#last_value ⇒ Object
Returns the value of attribute last_value.
6 7 8 |
# File 'lib/reacto/subscriptions/inner_subscription.rb', line 6 def last_value @last_value end |
Instance Method Details
#active? ⇒ Boolean
43 44 45 |
# File 'lib/reacto/subscriptions/inner_subscription.rb', line 43 def active? @active end |
#closed? ⇒ Boolean
47 48 49 |
# File 'lib/reacto/subscriptions/inner_subscription.rb', line 47 def closed? @closed end |
#unsubscribe ⇒ Object
38 39 40 41 |
# File 'lib/reacto/subscriptions/inner_subscription.rb', line 38 def unsubscribe @closed = true super end |