From acf2301fc91920f0cb98a54a93895b18f7447c26 Mon Sep 17 00:00:00 2001 From: ganfra Date: Sat, 12 Jan 2019 10:20:46 +0100 Subject: [PATCH] Use RxRelay instead of Subjects --- app/build.gradle | 1 + .../riotredesign/features/home/group/SelectedGroupHolder.kt | 6 +++--- .../riotredesign/features/home/room/VisibleRoomHolder.kt | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f96635de04..a79d178811 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" diff --git a/app/src/main/java/im/vector/riotredesign/features/home/group/SelectedGroupHolder.kt b/app/src/main/java/im/vector/riotredesign/features/home/group/SelectedGroupHolder.kt index 990e6fe8a0..5dc350d790 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/group/SelectedGroupHolder.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/group/SelectedGroupHolder.kt @@ -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.empty()) + private val selectedGroupStream = BehaviorRelay.createDefault>(Option.empty()) fun setSelectedGroup(group: GroupSummary?) { val optionValue = Option.fromNullable(group) - selectedGroupStream.onNext(optionValue) + selectedGroupStream.accept(optionValue) } fun selectedGroup(): Observable> { diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/VisibleRoomHolder.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/VisibleRoomHolder.kt index c288894359..c17ca4291e 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/VisibleRoomHolder.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/VisibleRoomHolder.kt @@ -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() + private val visibleRoomStream = BehaviorRelay.create() fun setVisibleRoom(roomId: String) { - visibleRoomStream.onNext(roomId) + visibleRoomStream.accept(roomId) } fun visibleRoom(): Observable {