Class: Reacto::Tracker

Inherits:
Object
  • Object
show all
Defined in:
lib/reacto/tracker.rb

Direct Known Subclasses

Subscriptions::OperationSubscription

Instance Method Summary collapse

Constructor Details

#initialize(open: NO_ACTION, value: NO_ACTION, error: DEFAULT_ON_ERROR, close: NO_ACTION) ⇒ Tracker

Returns a new instance of Tracker.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/reacto/tracker.rb', line 5

def initialize(
  open: NO_ACTION,
  value: NO_ACTION,
  error: DEFAULT_ON_ERROR,
  close: NO_ACTION
)
  @open = open
  @value = value
  @error = error
  @close = close
end

Instance Method Details

#on_closeObject



29
30
31
# File 'lib/reacto/tracker.rb', line 29

def on_close
  @close.call
end

#on_error(error) ⇒ Object



25
26
27
# File 'lib/reacto/tracker.rb', line 25

def on_error(error)
  @error.call(error)
end

#on_openObject



17
18
19
# File 'lib/reacto/tracker.rb', line 17

def on_open
  @open.call
end

#on_value(v) ⇒ Object



21
22
23
# File 'lib/reacto/tracker.rb', line 21

def on_value(v)
  @value.call(v)
end