Created
October 14, 2019 15:18
-
-
Save gabrielbmoro/6fb53b8d31eb4ca584f5efa57d4476d0 to your computer and use it in GitHub Desktop.
It is used to send notification from child views to parents
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
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