Class: Reacto::Operations::FlatMap
- Inherits:
-
Object
- Object
- Reacto::Operations::FlatMap
- Defined in:
- lib/reacto/operations/flat_map.rb
Instance Method Summary collapse
- #call(tracker) ⇒ Object
-
#initialize(transform) ⇒ FlatMap
constructor
A new instance of FlatMap.
Constructor Details
#initialize(transform) ⇒ FlatMap
Returns a new instance of FlatMap.
7 8 9 |
# File 'lib/reacto/operations/flat_map.rb', line 7 def initialize(transform) @transform = transform 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 29 |
# File 'lib/reacto/operations/flat_map.rb', line 11 def call(tracker) subscription = Subscriptions::FlatMapSubscription.new(tracker) value = ->(v) do trackable = @transform.call(v) trackable.do_track subscription.subscription! end close = ->() do subscription.source_closed = true return unless subscription.closed? tracker.on_close end Subscriptions::OperationSubscription.new( tracker, value: value, close: close ) end |