Sha256: 2ac085b4ccc4bfb1d4be7fde59ba751a3b65074b6f4e1ba5b19ab05dc3f75802
Contents?: true
Size: 732 Bytes
Versions: 3
Compression:
Stored size: 732 Bytes
Contents
# Handles temporary global subscriptions # @api private module Wisper class TemporaryListeners def self.subscribe(*listeners, &block) new.subscribe(*listeners, &block) end def self.registrations new.registrations end def subscribe(*listeners, &block) options = listeners.last.is_a?(Hash) ? listeners.pop : {} begin listeners.each { |listener| registrations << ObjectRegistration.new(listener, options) } yield ensure clear end self end def registrations Thread.current[key] ||= Set.new end private def clear registrations.clear end def key '__wisper_temporary_listeners' end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
siftery-wisper-2.0.1 | lib/wisper/temporary_listeners.rb |
wisper-2.0.0 | lib/wisper/temporary_listeners.rb |
wisper-2.0.0.rc1 | lib/wisper/temporary_listeners.rb |