Class: Reacto::Subscriptions::InnerSubscription

Inherits:
SimpleSubscription show all
Includes:
Subscription
Defined in:
lib/reacto/subscriptions/inner_subscription.rb

Instance Attribute Summary collapse

Attributes inherited from SimpleSubscription

#subscriptions

Instance Method Summary collapse

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_errorObject

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_valueObject

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

Returns:

  • (Boolean)


43
44
45
# File 'lib/reacto/subscriptions/inner_subscription.rb', line 43

def active?
  @active
end

#closed?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/reacto/subscriptions/inner_subscription.rb', line 47

def closed?
  @closed
end

#unsubscribeObject



38
39
40
41
# File 'lib/reacto/subscriptions/inner_subscription.rb', line 38

def unsubscribe
  @closed = true
  super
end