EventBusSwift 0.1.1

Simplifies the communication between components

Homepage: https://github.com/TVGSoft/EventBusSwift

Platform: CocoaPods

Language: Shell

License: MIT

Repository: https://github.com/TVGSoft/EventBusSwift.git

View on registry: http://cocoapods.org/pods/EventBusSwift

Documentation: http://cocoadocs.org/docsets/EventBusSwift/0.1.1

Install: pod try EventBusSwift


EventBusSwift

The idea come from https://github.com/greenrobot/EventBus in Android.

Requirements

  • iOS 8.0+ / Mac OS X 10.10+ / watchOS 2.0+ / tvOS 9.0+
  • Swift 3
    • Xcode 8.0+

Documentation

  1. Define Notification Name:

    extension Notification.Name {
    
        public static let Message = Notification.Name("Message")
    
    }
  2. Register and unregister your subscriber. For example on iOS, UIViewController should usually register according to their life cycle:

    func onViewWillAppear(_ animated: Bool) {
        super.onViewWillAppear(animated)
        EvenBus.shared.register(self, name: .Message) { [weak self] (object) in
            guard let _ = self else { return }
    
            if let text = object as? String {
                print(text)
            }
        }
    }
    
    func onViewWillDisappear(_ animated: Bool) {
        super.onViewWillDisappear(animated)
        EvenBus.shared.unregister(self, name: .Message)
    }
  3. Post events:

    EvenBus.shared.post(name: .Message, object: "Hello EventBus")

Releases

0.1.1 January 11, 2017

Project Statistics

SourceRank 7
Dependent repositories 0
Total releases 1
Latest release
First release
Stars 1
Forks 0
Watchers 1
Contributors 1
Repo Size: 42 KB

Top Contributors See all

TVGSoft

Something wrong with this page? Make a suggestion

Export .ABOUT file for this library

Last synced: 2017-03-27 14:19:20 UTC

Login to resync this project