Sha256: 390f1c2ade597e0740c0dc18ef5606484345f58bc0194f553b23230cda500635

Contents?: true

Size: 583 Bytes

Versions: 7

Compression:

Stored size: 583 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

7 entries across 7 versions & 1 rubygems

Version Path
bubble-wrap-1.8.0 motion/core/ns_notification_center.rb
bubble-wrap-1.7.1 motion/core/ns_notification_center.rb
bubble-wrap-1.7.0 motion/core/ns_notification_center.rb
bubble-wrap-1.6.0 motion/core/ns_notification_center.rb
bubble-wrap-1.6.0.rc1 motion/core/ns_notification_center.rb
bubble-wrap-1.5.0 motion/core/ns_notification_center.rb
bubble-wrap-1.5.0.rc1 motion/core/ns_notification_center.rb