https://github.com/therajanmaurya/rxbus-kotlin-example
RxBus Kotlin
https://github.com/therajanmaurya/rxbus-kotlin-example
kotlin kotlin-android rxbus2 rxjava2
Last synced: 6 months ago
JSON representation
RxBus Kotlin
- Host: GitHub
- URL: https://github.com/therajanmaurya/rxbus-kotlin-example
- Owner: therajanmaurya
- Created: 2018-07-23T08:55:39.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-23T18:38:04.000Z (about 7 years ago)
- Last Synced: 2025-04-15T05:52:15.583Z (6 months ago)
- Topics: kotlin, kotlin-android, rxbus2, rxjava2
- Language: Kotlin
- Homepage:
- Size: 209 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RxBus-Kotlin-Example
Medium Blog -> https://medium.com/@therajanmaurya/rxbus-kotlin-listen-where-ever-you-want-e6fc0760a4a8
Usage
-----Add [RxBus](RxBus.kt) and [RxEvent](RxEvent.kt) class in your project and you are done.
**To Publish Event**
```kt
RxBus.publish(RxEvent.EventAddPerson(etPersonName.text.toString()))
```**To Listen Event**
```kt
class MainActivity : AppCompatActivity() {private lateinit var disposable: Disposable
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)disposable = RxBus.listen(RxEvent.EventAddPerson::class.java).subscribe {
adapter.addPerson(person = it.personName) // whatever you wanna do with data
}
}override fun onDestroy() {
super.onDestroy()
if (!disposable.isDisposed) disposable.dispose()
}
}```