This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swagger: '2.0' | |
info: | |
title: Vector DB Client API | |
version: '1.0.0' | |
host: 'your-api.com' | |
schemes: | |
- https | |
basePath: /api/v1 | |
produces: | |
- application/json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ea.credgreen.testutils | |
import androidx.lifecycle.LiveData | |
import androidx.lifecycle.Observer | |
import com.ea.credgreen.assertWithTimeout | |
internal class DataRecorder<T> { | |
private val mutex = Any() | |
private val _values = mutableListOf<T?>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T> Observable<T>.debounceIf( | |
predicate: (T) -> Boolean, | |
timeout: Long, | |
unit: TimeUnit, | |
scheduler: Scheduler | |
): Observable<T> { | |
return this.publish { sharedSrc -> | |
Observable.merge( | |
sharedSrc.debounce(timeout, unit, scheduler) | |
.filter { predicate(it) }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val scheduler = TestScheduler() | |
val source = Observable.just(1) | |
.doOnSubscribe { | |
println("Hello World") | |
} | |
source | |
.debounceIf({ it == 1 }, 2, SECONDS, scheduler) | |
.test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val scheduler = TestScheduler() | |
val source = Observable.just(1) | |
.doOnSubscribe { | |
println("Hello World") | |
} | |
source | |
.debounceIf({ it == 1 }, 2, SECONDS, scheduler) | |
.test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T> Observable<T>.debounceIf( | |
... | |
): Observable<T> { | |
return Observable.merge( | |
debounce(timeout, unit, scheduler) | |
.filter { predicate(it) }, // The first stream | |
filter { !predicate(it) } // The second stream | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val source = PublishSubject.create<Int>() | |
source | |
.debounceIf({ it.isOdd }, 2, SECONDS, Schedulers.io()) | |
.subscribe { print(it) } | |
source.onNext(1) | |
source.onNext(2) | |
source.onNext(3) | |
source.onNext(4) | |
Thread.sleep(10000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T> Observable<T>.debounceIf( | |
predicate: (T) -> Boolean, | |
timeout: Long, | |
unit: TimeUnit, | |
scheduler: Scheduler | |
): Observable<T> { | |
return Observable.merge( | |
debounce(timeout, unit, scheduler) | |
.filter { predicate(it) }, | |
filter { !predicate(it) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val source = PublishSubject.create<Int>() | |
source | |
.debounceIf({ it.isOdd }, 2, SECONDS, Schedulers.io()) | |
.subscribe { print(it) } | |
source.onNext(1) | |
source.onNext(2) | |
source.onNext(3) | |
source.onNext(4) | |
Thread.sleep(10000) |
NewerOlder