Skip to content

Instantly share code, notes, and snippets.

@gabrielbmoro
Created October 14, 2019 15:18
Show Gist options
  • Save gabrielbmoro/6fb53b8d31eb4ca584f5efa57d4476d0 to your computer and use it in GitHub Desktop.
Save gabrielbmoro/6fb53b8d31eb4ca584f5efa57d4476d0 to your computer and use it in GitHub Desktop.
It is used to send notification from child views to parents
import io.reactivex.Observable
import io.reactivex.subjects.PublishSubject
class RxBus {
private val bus : PublishSubject<Any> = PublishSubject.create()
fun send(any : Any) = bus.onNext(any)
fun toObservable() : Observable<Any> = bus
}
// To use
RxBus.send(something)
RxBus.toObservable().suscribe({//do something})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment