Class: Reacto::Operations::OperationOnLabeled
- Inherits:
-
Object
- Object
- Reacto::Operations::OperationOnLabeled
- Defined in:
- lib/reacto/operations/operation_on_labeled.rb
Instance Method Summary collapse
- #call(tracker) ⇒ Object
-
#initialize(label, action, op: :map, **args) ⇒ OperationOnLabeled
constructor
A new instance of OperationOnLabeled.
Constructor Details
#initialize(label, action, op: :map, **args) ⇒ OperationOnLabeled
Returns a new instance of OperationOnLabeled.
6 7 8 9 10 11 |
# File 'lib/reacto/operations/operation_on_labeled.rb', line 6 def initialize(label, action, op: :map, **args) @op = op @action = action @label = label @args = args end |
Instance Method Details
#call(tracker) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/reacto/operations/operation_on_labeled.rb', line 13 def call(tracker) value = -> (v) do to_emit = if v.is_a?(LabeledTrackable) && v.label == @label v.send(@op, **@args, &@action) else v end tracker.on_value(to_emit) end Subscriptions::OperationSubscription.new(tracker, value: value) end |