there ```Observable.interval(2000, TimeUnit.MILLIS...
# rx
o
there
Copy code
Observable.interval(2000, TimeUnit.MILLISECONDS)
                .repeatUntil {
                    System.currentTimeMillis() - startTime > 10000
                    true
                }
                .subscribe {
                    purchaseFlowStore
                        .getTransaction(transactionId)
                        .viewModelSubscription({
                            when (it.state) {
                                "done", "authorized" -> {
                                    getOrder()
                                }
                                "error" -> {
                                    showErrorDialog()
                                }
                            }
                        }, {
                            showErrorDialog()
                        })
                }
m
you are doing it wrong. That way, you will get multiple subscriptions active. And the first emission will be delayed 2s
try this
Copy code
class RxTest {
    private val count = AtomicInteger(0)
    private fun getEndpointValue(): Observable<Int>{
        return Observable.just(count.getAndIncrement())
    }


    @Test
    fun `test interval` () {
        Assert.assertEquals(
            Observable.interval(0, 1, TimeUnit.SECONDS)
                .switchMap { getEndpointValue() }
                .filter { value -> value == 5 }
                .take(1)
                .blockingFirst(),
            5
        )
    }
}
👍🏻 1