A super simple wrapper around NotificationCenter.
pod 'SwiftNotes'
Or just drop SwiftNotes.swift into your project.
when(.UIKeyboardDidShow) { note in
// do stuff
}
when(.UIApplicationDidBecomeActive) { _ in
// do stuff
}
// define the custom event name
extension NSNotification.Name {
static let somethingHappened = Notification.Name("somethingHappened")
}
// send your custom event
trigger(.somethingHappened)
when(.somethingHappened) { _ in
// do stuff
}
trigger(.somethingHappened, userInfo: ["goodTimes": true])
trigger(.updatedFromRemote, on: self)
when(model, does: .updatedFromRemote) { _ in
// do stuff
}
// make sure the closure is run on the main queue
when(.somethingHappened, doOn: OperationQueue.main) _ in
// do stuff
}