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
// RetryWithDelay 使用例 | |
fun main(args: Array<String>) { | |
Observable.create<String> { subscriber -> | |
subscriber.onNext("test") | |
subscriber.onError(Throwable("error occurred")) | |
} | |
.retryWhen(RetryWithDelay(3, 1000L)) | |
// toBlocking() や Thread.sleep() 的なものがないとメインスレッドが一瞬で終了してリトライ中の処理ごと死んでしまう | |
// 実処理では blocking するわけに行かないので処理中に死んだ場合を考慮する必要があるかも | |
// -> Android なら onStop() での unsubscribe() ? 要調査 |