https://kotlinlang.org logo
#rx
Title
# rx
o

oday

12/08/2020, 10:31 AM
Copy code
purchaseFlowStore
            .getTransaction(transactionId)
            .takeUntil { it.state == "done" || it.state == "error" || it.state == "authorized" }
            .doOnError {
                logger.debug("TransactionInfo error! $it")
            }
            .repeatWhen { Observable.timer(5, TimeUnit.SECONDS) }
            .viewModelSubscription({
                logger.debug("TransactionInfo is ${it.state}")

                when (it.state) {
                    "done", "authorized" -> {
                        getOrder()
                    }
                    "error" -> {
                        ShowRequestFailedDialog()
                    }
                }
            }, {
                logger.debug("TransactionInfo error! $it")
            })
s

StavFX

12/08/2020, 6:32 PM
Your repeatWhen needs to react to onComplete events, and not just start its own timer.
.repeatWhen { completed -> completed.delay(5, TimeUnit.SECONDS) }
or
Copy code
.repeatWhen { completed -> 
   completed.flatMap { Observable.timer(5, TimeUnit.SECONDS) } 
}
4 Views