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