mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 12:08:34 +00:00
Remove some unnecessary call tab requeries.
This commit is contained in:
@@ -73,3 +73,20 @@ fun <S : Subject<T>, T : Any> Single<T>.subscribeWithSubject(
|
||||
|
||||
return subject
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips the first item emitted from the flowable, but only if it matches the provided [predicate].
|
||||
*/
|
||||
fun <T : Any> Flowable<T>.skipFirstIf(predicate: (T) -> Boolean): Flowable<T> {
|
||||
return this
|
||||
.scan(Pair<Boolean, T?>(false, null)) { acc, item ->
|
||||
val firstItemInList = !acc.first
|
||||
if (firstItemInList && predicate(item)) {
|
||||
true to null
|
||||
} else {
|
||||
true to item
|
||||
}
|
||||
}
|
||||
.filter { it.second != null }
|
||||
.map { it.second!! }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user