Class: Reacto::Operations::FindIndex
- Inherits:
-
Object
- Object
- Reacto::Operations::FindIndex
- Defined in:
- lib/reacto/operations/find_index.rb
Instance Method Summary collapse
- #call(tracker) ⇒ Object
-
#initialize(predicate) ⇒ FindIndex
constructor
A new instance of FindIndex.
Constructor Details
#initialize(predicate) ⇒ FindIndex
Returns a new instance of FindIndex.
6 7 8 |
# File 'lib/reacto/operations/find_index.rb', line 6 def initialize(predicate) @predicate = predicate end |
Instance Method Details
#call(tracker) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/reacto/operations/find_index.rb', line 10 def call(tracker) index = 0 behaviour = -> (value) do found = @predicate.call(value) if found tracker.on_value(index) tracker.on_close else index += 1 end end Subscriptions::OperationSubscription.new(tracker, value: behaviour) end |