Class: Reacto::Operations::DelayEach
- Inherits:
-
Object
- Object
- Reacto::Operations::DelayEach
- Defined in:
- lib/reacto/operations/delay_each.rb
Defined Under Namespace
Classes: TaskObserver
Instance Method Summary collapse
- #call(tracker) ⇒ Object
-
#initialize(delay) ⇒ DelayEach
constructor
A new instance of DelayEach.
Constructor Details
#initialize(delay) ⇒ DelayEach
Returns a new instance of DelayEach.
20 21 22 23 |
# File 'lib/reacto/operations/delay_each.rb', line 20 def initialize(delay) @delay = delay @queue = [] end |
Instance Method Details
#call(tracker) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/reacto/operations/delay_each.rb', line 25 def call(tracker) close = lambda do @queue << OpenStruct.new(type: :close) delay_task(tracker) end error = lambda do |e| @queue << OpenStruct.new(error: e, type: :error) delay_task(tracker) end value = lambda do |v| @queue << OpenStruct.new(value: v, type: :value) delay_task(tracker) end Subscriptions::OperationSubscription.new( tracker, value: value, close: close, error: error ) end |