SwiftObserverCenter is a notification centers built based on protocol, which provides better use experience than the Apple Native NSNotificationCenter.
Because of Generics AnyObject, protocol must use @objc now,If you have a better way, please let me know.
@objc protocol Topic {
func receiveMsg(msg: String,from: String)
}
AddObserver(topic: Topic.self, observer: self);
PublishObserver(topic: Topic.self) { topic in
topic.receiveMsg(msg: "你今天摸鱼了吗?", from: "张三")
}
RemoveObserver(topic: Topic.self, observer: self)
To install it, simply add the following line to your Podfile:
pod "SwiftObserverCenter"
corotata, corotata@qq.com
SwiftObserverCenter is available under the MIT license. See the LICENSE file for more info.