Skip to content

Instantly share code, notes, and snippets.

@wellingtoncosta
Last active January 24, 2019 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wellingtoncosta/ea43f4636d6bfcf03195b5ef220864a0 to your computer and use it in GitHub Desktop.
Save wellingtoncosta/ea43f4636d6bfcf03195b5ef220864a0 to your computer and use it in GitHub Desktop.
class RxBus private constructor() {
private val subject = PublishSubject.create<Any>()
fun publish(message: Any) {
subject.onNext(message)
}
fun subscribe(action: (Any) -> Unit): Disposable {
return subject.subscribe { action(it) }
}
companion object {
val instance by lazy { RxBus() }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment