Only show connection warning if not actively connected.

This commit is contained in:
Greyson Parrelli
2024-11-01 09:33:33 -04:00
parent 3310762970
commit 4446510916
3 changed files with 30 additions and 5 deletions

View File

@@ -0,0 +1,23 @@
/*
* Copyright 2024 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.signal.core.util.concurrent
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.Observer
import io.reactivex.rxjava3.subjects.BehaviorSubject
/**
* An Observer that provides instant access to the latest emitted value.
* Basically a read-only version of [BehaviorSubject].
*/
class LatestValueObservable<T : Any>(private val subject: BehaviorSubject<T>) : Observable<T>() {
val value: T?
get() = subject.value
override fun subscribeActual(observer: Observer<in T>) {
subject.subscribe(observer)
}
}