Class: Reacto::SharedTrackable
Constant Summary
Constants inherited
from Trackable
Trackable::TOPICS
Instance Method Summary
collapse
Methods inherited from Trackable
#[], #act, #await, #buffer, #cache, close, combine, combine_last, combine_with, #concat, #delay, #depend_on, #diff, #do_track, #drop, #drop_errors, enumerable, error, #execute_on, #first, #flat_map, #flat_map_latest, #flatten, #inject, interval, #label, #last, later, #lift, make, #map, #merge, never, #on, #prepend, repeat, #select, #take, #throttle, #track_on, #uniq, value, #wrap, zip
Constructor Details
#initialize(behaviour = NO_ACTION, executor = nil, activate_on_subscribe = false, &block) ⇒ SharedTrackable
Returns a new instance of SharedTrackable.
5
6
7
8
9
10
11
12
13
|
# File 'lib/reacto/shared_trackable.rb', line 5
def initialize(
behaviour = NO_ACTION, executor = nil, activate_on_subscribe = false,
&block
)
super(behaviour, executor, &block)
@activate_on_subscribe = activate_on_subscribe
@active = false
end
|
Instance Method Details
#activate! ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/reacto/shared_trackable.rb', line 37
def activate!
return if @shared_subscription.nil?
return if @active
@active = true
do_track(shared_subscription)
self
end
|
#activate_on_subscribe ⇒ Object
47
48
|
# File 'lib/reacto/shared_trackable.rb', line 47
def activate_on_subscribe
end
|
#off(notification_tracker = nil) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/reacto/shared_trackable.rb', line 15
def off(notification_tracker = nil)
shared_subscription.subscriptions.reject! do |subscription|
!subscription.subscribed?
end
return if shared_subscription.subscriptions.count > 0
shared_subscription.unsubscribe
@shared_subscription = nil
@active = false
end
|
#track(notification_tracker) ⇒ Object