An statically typed event hub built on Swift generics and Apple's NotificationCenter.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Original gist is here:

There's a blog post about this repository:

And here's a usage example:

 Statically declare all domain events, along with the type of extra information the
 event will carry with it.
extension Events {
    static let userUpdated = Event<User?>("UserUpdated")

struct User {
    let name: String

let hub = Hub()

hub.observe(.userUpdated) { user in
    if let user = user {
        debugPrint("New user: \(")
    } else {
        debugPrint("User disappeared!")
}, User(name: "")), nil)


Pull requests are very welcome!

Some thoughts regarding possible changes or updates:

  • We're using object, but perhaps userInfo is better with a known key?
  • We don't allow specifying object in observe or post.
  • We don't allow specifying queue in observe.
  • There's no alternative with an observer that auto-cancels on deinit.
  • There's no observe that observes just once.
  • Would be nice to turn this into a Cocoapod/Carthage/Swift Package.


MIT license.