Class: Reacto::Operations::Last
- Inherits:
-
Object
- Object
- Reacto::Operations::Last
- Defined in:
- lib/reacto/operations/last.rb
Instance Method Summary collapse
- #call(tracker) ⇒ Object
-
#initialize ⇒ Last
constructor
A new instance of Last.
Constructor Details
#initialize ⇒ Last
Returns a new instance of Last.
6 7 8 9 |
# File 'lib/reacto/operations/last.rb', line 6 def initialize @marker = {} @prev = @marker end |
Instance Method Details
#call(tracker) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/reacto/operations/last.rb', line 11 def call(tracker) close = lambda do tracker.on_value(@prev) if @prev != @marker tracker.on_close end error = lambda do |e| tracker.on_value(@prev) if @prev != @marker tracker.on_error(e) end Subscriptions::OperationSubscription.new( tracker, value: -> (v) { @prev = v }, error: error, close: close ) end |