Last active
January 24, 2019 14:24
-
-
Save wellingtoncosta/ea43f4636d6bfcf03195b5ef220864a0 to your computer and use it in GitHub Desktop.
This file contains 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
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