Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. object RxBus {
  2.  
  3. private val publisher = PublishSubject.create<Any>()
  4.  
  5. fun publish(event: Any) {
  6. publisher.onNext(event)
  7. }
  8.  
  9. // Listen should return an Observable and not the publisher
  10. // Using ofType we filter only events that match that class key
  11. fun <T : Any> listen(eventType: Class<T>): Observable<T> = publisher.ofType(eventType)
  12.  
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement