Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object RxBus {
- private val publisher = PublishSubject.create<Any>()
- fun publish(event: Any) {
- publisher.onNext(event)
- }
- // Listen should return an Observable and not the publisher
- // Using ofType we filter only events that match that class key
- fun <T : Any> listen(eventType: Class<T>): Observable<T> = publisher.ofType(eventType)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement