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.


111
112
113
# File 'lib/ruby_event_store/subscriptions.rb', line 111

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

Instance Method Details

#add(subscription) ⇒ Object


115
116
117
118
# File 'lib/ruby_event_store/subscriptions.rb', line 115

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

#all_for(_event_type) ⇒ Object


120
121
122
# File 'lib/ruby_event_store/subscriptions.rb', line 120

def all_for(_event_type)
  @subscriptions.value
end