https://github.com/i60r/activityrx
RxJava bindings to Activities
https://github.com/i60r/activityrx
activity android lifecycle rxjava
Last synced: about 2 months ago
JSON representation
RxJava bindings to Activities
- Host: GitHub
- URL: https://github.com/i60r/activityrx
- Owner: I60R
- License: mit
- Created: 2017-04-23T22:34:38.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-01T16:51:50.000Z (about 9 years ago)
- Last Synced: 2025-01-16T22:47:12.448Z (over 1 year ago)
- Topics: activity, android, lifecycle, rxjava
- Language: Java
- Homepage:
- Size: 140 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Manage Android Activities in reactive way
**without inheritance**
[](https://jitpack.io/#I60R/ActivityRx)
[](https://github.com/160R/ActivityRx)
--------
--------
```kotlin
ActivityRx.init(this)
Activities.events()
.subscribe {
Log.d("ActivitiesLogger", "${it.id} ~> ${it.on}")
if (it.on == On.RESUME) {
Log.d("ActivitiesLogger", "*\n*\n*\n")
}
}
```
--------
--------
```kotlin
Activities.current()
.filter { it.usable }
.subscribe({
it.ui.finish()
}, {}, {
Log.d("ActivitiesManager", "finish all activities")
})
```
--------
--------
```kotlin
Activities.observe(MainActivity::class.java)
.subscribe {
Log.d("MainActivityLogger", "${it.on}")
}
```
--------
--------
```kotlin
Activities
.bind(MainActivity::class.java)
.subscribe({}, {}, {
Log.d("MainActivityBinding", "activity destroyed")
})
```
--------
--------
```kotlin
Activities.start(MainActivity::class.java)
.filter { it.visible }.firstElement()
.flatMap { it.ui.getUserInput() }
.flatMap { validate(it) }
.flatMap {
Activities.start(SecondActivity::class.java, Bundle().apply { putString("inp", it) })
.filter { it.visible }.firstElement()
}
.subscribe {
it.ui.displayInputFromBundle()
}
```