Use RxRelay instead of Subjects

This commit is contained in:
ganfra 2019-01-12 10:20:46 +01:00 committed by ganfra
parent d7de986365
commit acf2301fc9
3 changed files with 7 additions and 5 deletions

View file

@ -65,6 +65,7 @@ dependencies {
// rx
implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.0'
implementation("com.airbnb.android:epoxy:$epoxy_version")
kapt "com.airbnb.android:epoxy-processor:$epoxy_version"

View file

@ -1,17 +1,17 @@
package im.vector.riotredesign.features.home.group
import arrow.core.Option
import com.jakewharton.rxrelay2.BehaviorRelay
import im.vector.matrix.android.api.session.group.model.GroupSummary
import io.reactivex.Observable
import io.reactivex.subjects.BehaviorSubject
class SelectedGroupHolder {
private val selectedGroupStream = BehaviorSubject.createDefault<Option<GroupSummary>>(Option.empty())
private val selectedGroupStream = BehaviorRelay.createDefault<Option<GroupSummary>>(Option.empty())
fun setSelectedGroup(group: GroupSummary?) {
val optionValue = Option.fromNullable(group)
selectedGroupStream.onNext(optionValue)
selectedGroupStream.accept(optionValue)
}
fun selectedGroup(): Observable<Option<GroupSummary>> {

View file

@ -1,14 +1,15 @@
package im.vector.riotredesign.features.home.room
import com.jakewharton.rxrelay2.BehaviorRelay
import io.reactivex.Observable
import io.reactivex.subjects.BehaviorSubject
class VisibleRoomHolder {
private val visibleRoomStream = BehaviorSubject.create<String>()
private val visibleRoomStream = BehaviorRelay.create<String>()
fun setVisibleRoom(roomId: String) {
visibleRoomStream.onNext(roomId)
visibleRoomStream.accept(roomId)
}
fun visibleRoom(): Observable<String> {