mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-26 14:09:58 +00:00
Reimplement MessageRequestViewModel for CFV2.
This commit is contained in:
@@ -6,9 +6,12 @@ import android.annotation.SuppressLint
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import io.reactivex.rxjava3.core.Completable
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import io.reactivex.rxjava3.core.Observable
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.addTo
|
||||
import io.reactivex.rxjava3.kotlin.subscribeBy
|
||||
import java.lang.RuntimeException
|
||||
import io.reactivex.rxjava3.subjects.Subject
|
||||
|
||||
/**
|
||||
* Throw an [InterruptedException] if a [Single.blockingGet] call is interrupted. This can
|
||||
@@ -42,3 +45,16 @@ fun Completable.observe(viewLifecycleOwner: LifecycleOwner, onComplete: () -> Un
|
||||
lifecycleDisposable.bindTo(viewLifecycleOwner)
|
||||
lifecycleDisposable += subscribeBy(onComplete = onComplete)
|
||||
}
|
||||
|
||||
fun <S : Subject<T>, T : Any> Observable<T>.subscribeWithSubject(
|
||||
subject: S,
|
||||
disposables: CompositeDisposable
|
||||
): S {
|
||||
subscribeBy(
|
||||
onNext = subject::onNext,
|
||||
onError = subject::onError,
|
||||
onComplete = subject::onComplete
|
||||
).addTo(disposables)
|
||||
|
||||
return subject
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user