Class: RubyEventStore::Subscriptions::ThreadGlobalSubscriptions

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/subscriptions.rb

Instance Method Summary collapse

Constructor Details

#initializeThreadGlobalSubscriptions

Returns a new instance of ThreadGlobalSubscriptions.



95
96
97
# File 'lib/ruby_event_store/subscriptions.rb', line 95

def initialize
  @subscriptions = Concurrent::ThreadLocalVar.new([])
end

Instance Method Details

#add(subscription) ⇒ Object



99
100
101
102
# File 'lib/ruby_event_store/subscriptions.rb', line 99

def add(subscription)
  @subscriptions.value += [subscription]
  -> { @subscriptions.value -= [subscription] }
end

#all_for(_event_type) ⇒ Object



104
105
106
# File 'lib/ruby_event_store/subscriptions.rb', line 104

def all_for(_event_type)
  @subscriptions.value
end