Guest User

Untitled

a guest
Jan 17th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. class RxBus private constructor() {
  2.  
  3. private val subject = PublishSubject.create<Any>()
  4.  
  5. fun publish(message: Any) {
  6. subject.onNext(message)
  7. }
  8.  
  9. fun subscribe(action: (Any) -> Unit): Disposable {
  10. return subject.subscribe { action(it) }
  11. }
  12.  
  13. companion object {
  14. val instance by lazy { RxBus() }
  15. }
  16.  
  17. }
Add Comment
Please, Sign In to add comment