Class: Reacto::Operations::Cache
- Inherits:
-
Object
- Object
- Reacto::Operations::Cache
- Defined in:
- lib/reacto/operations/cache.rb
Constant Summary collapse
Instance Method Summary collapse
- #call(tracker) ⇒ Object
-
#initialize(type: :memory, **settings) ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
Instance Method Details
#call(tracker) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/reacto/operations/cache.rb', line 20 def call(tracker) if @cache.ready? @cache.each do |value| tracker.on_value(value) end if @cache.error? tracker.on_error(@cache.error) else tracker.on_close end NOTHING else Subscriptions::OperationSubscription.new( tracker, value: -> (v) do @cache.on_value(v) tracker.on_value(v) end, error: -> (e) do @cache.on_error(e) tracker.on_error(e) end, close: -> () do @cache.on_close tracker.on_close end ) end end |