Project provides basic idea and approach to implement the NotificationCenter by using Pubs/Subs Pattern, and Observer design pattern, this pattern oppose to create strong reference cycle because of weak reference of protocol.
- Drag and drop the file SNotificationManager in your project
- Susbscribe the Observer By: SNotificationManager.addObserver(observer: self, type: .jwtTokenExpired, selector: #selector(tokenExpired(noti:)))
- Publish the Observer By: SNotificationManager.postObserver(type: .jwtTokenExpired, object: true)
- Receive the Observers By: ' @objc fileprivate func tokenExpired(noti: NSNotification) { if let expired = noti.object as? Bool { print(" expired: (expired)") } }'
-
Add Observers By: SObserverManager.shared.addObserver(observer: self)
-
Connfirm the protocol By: ' extension ViewController :SObserver { func notifyUpdate() { print("Observers notified") }
}' -
Remove Observer By: ' deinit { SObserverManager.shared.removeObserver(observer: self) }'
SNotificationCenter is available under the MIT license. See the LICENSE file for more info.
- SPopupMenu:- Simple UI for create the POP list for menu with Text, Text With Icon, Muliti Seelction.