Sha256: 4696bff4585d06452659e8020421c3ce053e501e86a77980cf41cd2cf784befc

Contents?: true

Size: 580 Bytes

Versions: 1

Compression:

Stored size: 580 Bytes

Contents

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

  def observe(name, object=nil, &proc)
    proc.weak! if proc && ChaWork.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

1 entries across 1 versions & 1 rubygems

Version Path
cha_work-0.1 lib/cha_work/sugar/notificationcenter.rb