Sha256: d6e5d1d85812208cd1d1b74a30088794c8f5252f0296a97efcf3864da60ea9dc

Contents?: true

Size: 582 Bytes

Versions: 8

Compression:

Stored size: 582 Bytes

Contents

class NSNotificationCenter
  def observers
    @observers ||= []
  end

  def observe(name, object=nil, &proc)
    proc.weak! if proc && BubbleWrap.use_weak_callbacks?
    observer = self.addObserverForName(name, object:object, queue:NSOperationQueue.mainQueue, usingBlock:proc)
    observers << observer
    observer
  end

  def unobserve(observer)
    return unless observers.include?(observer)
    removeObserver(observer)
    observers.delete(observer)
  end

  def post(name, object=nil, info=nil)
    self.postNotificationName(name, object: object, userInfo: info)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bubble-wrap-1.9.7 motion/core/ns_notification_center.rb
bubble-wrap-1.9.6 motion/core/ns_notification_center.rb
bubble-wrap-1.9.5 motion/core/ns_notification_center.rb
bubble-wrap-1.9.4 motion/core/ns_notification_center.rb
bubble-wrap-1.9.3 motion/core/ns_notification_center.rb
bubble-wrap-1.9.2 motion/core/ns_notification_center.rb
bubble-wrap-1.9.1 motion/core/ns_notification_center.rb
bubble-wrap-1.9.0 motion/core/ns_notification_center.rb