10

Here’s an open source library from Alec Larson providing a Swift based alternative to NSNotificationCenter with a very clean and simple syntax.

This example from the readme shows how simple it is to create a generic emitter with EmitterKit:

let didLogin = Event()

didLogin.once { user in
  println("Successfully logged in as \(user.name)!")
}

didLogin.emit(user)

The advantages of EmitterKit as stated in the readme include:

  • No longer be forced to typecast event data in your closures.
  • No longer be forced to removeObserver in your classes’ deinit methods.
  • Backwards-compatible with NSNotificationCenter (like UIKeyboardWillShowNotification)!
  • Simpler syntax

You can find Emitter-Kit on Github here.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>