Latest 0.0.1
License MIT
Platforms ios 10.0, requires ARC
Dependencies RxSwift, RxCocoa
Frameworks UIKit

Build Status


This project contains some extensions on top of NSNotificationCenter that allows the creation of strong-typed notifications. My goal was to have a type-safe, reactive and easier-to-use mechanism.

How to use them?

1. Declare the notification type

Create a struct, enum, or class, that will represent the notification using the type system. :

enum UserNotification : String, Notifiable {
    typealias ParameterType = User

    case userDidLogin
    case userDidLogout

1. Subscribe to the notification

Subscribe to the notification and use the parameter directly.

⚠️ Notice that this is type safe, you don’t need to extract the parameter and cast it!
The extensions will safely do that.

Option 1: Add a listener to the notification

        .addListener { [unowned self] (user: User) in
            self.loadPreferences(of: user) 
        .disposed(by: disposeBag)

Option 2: You can also treat the notification like a regular Observable:

        .subscribe(onNext:{ [unowned self] (user:User) in
            self.loadPreferences(of: user)
        .disposed(by: disposeBag)

Notifications with no parameters.

NoParamsNotifiable, lets you post notifications with no parameters:

    enum CalendarNotification : NoParamsNotifiable {
        case calendarDidSynchronize

            print("Calendar synchronized")

Test cases

To run the example project, clone the repo, and run pod install from the Example directory first.
It contains a set of unit tests that explain how to use other features.



RxSwiftNotifications is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'RxSwiftNotifications'


Leandro Perez, [email protected]


RxSwiftNotifications is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "RxSwiftNotifications",
    "version": "0.0.1",
    "platforms": {
        "ios": "10.0"
    "requires_arc": true,
    "summary": "A small group of extensions on top of NSNotification center and RxSwift that allows for strong-typed notifications",
    "description": "Have strong-typed notifications and parameters. Easyly register listeners and access the parameters of the notification with no boilerplate code. Transform the notification in a rx observavble to react to it in a seamless way.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Leandro Perez": "[email protected]"
    "social_media_url": "",
    "source": {
        "git": "",
        "tag": "0.0.1"
    "source_files": "RxSwiftNotifications/Classes/**/*",
    "frameworks": "UIKit",
    "swift_version": "4.2",
    "dependencies": {
        "RxSwift": [],
        "RxCocoa": []

Pin It on Pinterest

Share This