Sha256: a7d3814a116b488ecf2487111e0df1048e37c814fbde6b73e86fa16e1f356ac6
Contents?: true
Size: 845 Bytes
Versions: 2
Compression:
Stored size: 845 Bytes
Contents
# Handles temporary global subscriptions # @api private module Wisper class TemporaryListeners def self.subscribe(*listeners, **options, &block) new.subscribe(*listeners, **options, &block) end def self.registrations new.registrations end def subscribe(*listeners, **options, &_block) new_registrations = build_registrations(*listeners, **options) begin registrations.merge new_registrations yield ensure registrations.subtract new_registrations end self end def registrations Thread.current[key] ||= Set.new end private def build_registrations(*listeners, **options) listeners.map { |listener| ObjectRegistration.new(listener, **options) } end def key '__wisper_temporary_listeners' end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
wisper-3.0.0.rc1 | lib/wisper/temporary_listeners.rb |
wisper-compat-4.0.0 | lib/wisper/temporary_listeners.rb |