mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-21 11:38:36 +00:00
Convert device linking apis to use websockets.
This commit is contained in:
committed by
Michelle Tang
parent
451d12ed53
commit
c38342e2fb
@@ -1,8 +1,12 @@
|
||||
/*
|
||||
* Copyright 2025 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
@file:JvmName("RxExtensions")
|
||||
|
||||
package org.signal.core.util.concurrent
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import io.reactivex.rxjava3.core.Completable
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
@@ -13,27 +17,6 @@ import io.reactivex.rxjava3.kotlin.addTo
|
||||
import io.reactivex.rxjava3.kotlin.subscribeBy
|
||||
import io.reactivex.rxjava3.subjects.Subject
|
||||
|
||||
/**
|
||||
* Throw an [InterruptedException] if a [Single.blockingGet] call is interrupted. This can
|
||||
* happen when being called by code already within an Rx chain that is disposed.
|
||||
*
|
||||
* [Single.blockingGet] is considered harmful and should not be used.
|
||||
*/
|
||||
@SuppressLint("UnsafeBlockingGet")
|
||||
@Throws(InterruptedException::class)
|
||||
fun <T : Any> Single<T>.safeBlockingGet(): T {
|
||||
try {
|
||||
return blockingGet()
|
||||
} catch (e: RuntimeException) {
|
||||
val cause = e.cause
|
||||
if (cause is InterruptedException) {
|
||||
throw cause
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Any> Flowable<T>.observe(viewLifecycleOwner: LifecycleOwner, onNext: (T) -> Unit) {
|
||||
val lifecycleDisposable = LifecycleDisposable()
|
||||
lifecycleDisposable.bindTo(viewLifecycleOwner)
|
||||
|
||||
Reference in New Issue
Block a user