Class: Reactive::Observable::First::Observer

Inherits:
Reactive::ObserverWrapper show all
Defined in:
lib/Reactive/observable/first.rb

Instance Attribute Summary

Attributes inherited from Reactive::ObserverWrapper

#parent, #target

Instance Method Summary collapse

Methods inherited from Reactive::ObserverWrapper

#active?, #attributes, #on_complete, #unwrap, #unwrap_parent, #wrap_with_parent

Constructor Details

#initialize(*args) ⇒ Observer

Returns a new instance of Observer.



8
9
10
11
# File 'lib/Reactive/observable/first.rb', line 8

def initialize(*args)
  @taken = 0
  super
end

Instance Method Details

#on_next(value) ⇒ Object

??? count is nilled (since it’s an attribute), but we might not want it to… can be less change attribute nilling on unwrap to opt in/out or write unwrap method? or leave as is because everything is sort of perfect?



16
17
18
19
20
# File 'lib/Reactive/observable/first.rb', line 16

def on_next(value)
  @target.on_next(value)
  @taken += 1
  on_complete if @taken == @count
end