Skip to content

`RxEventHub` makes multicasting event easy, type-safe and error-free, use it instead of `NSNotificationCenter` now!

License

Notifications You must be signed in to change notification settings

RxSwiftCommunity/RxEventHub

Repository files navigation

RxEventHub

CI Status Version License Platform

Overview

RxEventHub is an event hub in RxSwift world, it makes multicasting event easy, type-safe and error-free, it's intent to replace usage of NSNotificationCenter in most cases.

To make multicasting event type-safe and error-free, this lib provides RxEventProvider with generic type. For each type of event you want to send and observe, you create a subclass of RxEventProvider, just like below:

class ExampleIntEventProvider: RxEventProvider<Int>{}

This class is used to provide type info and event name. You may override the typeKey method to provide custom event name.

You can notify the hub when events occur by simply writing 1 line code like below:

RxEventHub.sharedHub.notify(ExampleIntEventProvider(), data: 2)

You can get the Observable (Observable<Int> in this example) when events occur by simply writing 1 line code like below:

RxEventHub.sharedHub.eventObservable(ExampleIntEventProvider())

One more thing, you can either use the default hub RxEventHub.sharedHub, or create different hubs for different modules as you want.

Requirements

  • Swift 3 (use 0.1.1 version for Swift 2)

Installation

CocoaPods

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

pod "RxEventHub"

Manual

Just copy RxEventHub.swift into your project, and you're ready to go.

License

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

About

`RxEventHub` makes multicasting event easy, type-safe and error-free, use it instead of `NSNotificationCenter` now!

Resources

License

Stars

Watchers

Forks

Packages

No packages published