Last active
June 26, 2016 08:56
-
-
Save AAverin/60f22b90192aaea5ab1c36ef6d38b798 to your computer and use it in GitHub Desktop.
RxBus gist for CleanAndroidCode article series https://medium.com/@anton.averin.dev/keep-your-droid-clean-e9c093140eb6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open class RxBus { | |
private val bus = SerializedSubject<BusEvent, BusEvent>(PublishSubject.create()); | |
fun post(event: BusEvent) { | |
bus.onNext(event) | |
} | |
fun <T> events(type: Class<T>): Observable<T> { | |
return events().ofType(type) | |
} | |
fun events(): Observable<BusEvent> { | |
return bus.asObservable() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment