A protocol-oriented, type-safe, thread-safe, and memory-safe notification center for Swift.
SwiftNotificationCenter is a protocol-oriented notification center for Swift that provides type-safe, thread-safe, and memory-safe one-to-many communication. It replaces Apple's NSNotificationCenter with a modern API that eliminates unsafe practices like using `userInfo` dictionaries and manual observer management.
Swift developers building iOS or macOS applications who need a safer and more expressive alternative to NSNotificationCenter for handling notifications and observer patterns.
Developers choose SwiftNotificationCenter because it offers compile-time type safety, automatic memory management, and thread safety out of the box, reducing bugs and boilerplate code compared to traditional notification systems.
A Protocol-Oriented NotificationCenter which is type safe, thread safe and with memory safety
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Eliminates the need for `userInfo` dictionaries and downcasting by delivering concrete type values to observers, as shown in the README's comparison with NSNotificationCenter.
Supports register, notify, and unregister operations from any thread without crashes or data corruption, ensuring safe multithreaded use.
Stores observers as zeroing-weak references, preventing crashes and eliminating the need for manual unregistration, which reduces memory leak risks.
Offers a simple and expressive API based on Swift protocols, making it easy to integrate and use for one-to-many communication, as highlighted in the usage examples.
Requires defining a separate protocol for each notification type, which can be verbose and add boilerplate compared to NSNotificationCenter's string-based keys.
For observing system notifications like UIKeyboardWillShow, you must declare a protocol and use a singleton mediator, adding extra steps as admitted in the README.
Only compatible with Swift projects, so it cannot be used in mixed Objective-C/Swift environments without additional bridging work, limiting cross-language adoption.
SwiftNotificationCenter is an open-source alternative to the following products: