but the output is still the same : trying value Th...
# rx
n
but the output is still the same : trying value Thu Mar 23 181508 CET 2017 trying value Thu Mar 23 181510 CET 2017 trying value Thu Mar 23 181512 CET 2017 3 true because the 5 seconds timeout start only after the first emission (181508). If I return true at the 4th iteration, the timeout will occurs, at 181513
b
It is working as expected
The delay in repeatWhen applies the 2 second delay after the observable has completed (and emitted a value)
So you subscribe on 00.00 get the first value milliseconds after on 00.xx, the second value on 02.xx and the third on 04.xx, before the timeout
use something like
fun now() = System.currentTimeMillis().toString().takeLast(5)
instead of Date() for timestamps to see it clearer
n
ok i’ll gonna try
Well yeah I don’t understand how I misreaded this
actually seems logical the day after ^^ ty !
b
No prob, you can also add a delay to the original observable to see how it will timeout
Copy code
Observable
            .fromCallable { nbTries++ >= 2 }
            .delay(1, TimeUnit.SECONDS)
            .doOnNext { println("Trying value ${now()}") }
            .repeatWhen { it.delay(2, TimeUnit.SECONDS) }
            .filter { it }
            .timeout(5, TimeUnit.SECONDS)
            .firstOrError()
            .doOnSubscribe { println("Start ${now()}") }
            .subscribe({ println("$nbTries $it ${now()}") }
                    ,
                    { println("Timeout ${now()}") })