LoginSignup
2
0

More than 5 years have passed since last update.

RxJavaで再帰呼出し

Last updated at Posted at 2017-12-07

RxJava使って再帰呼び出ししたいなと思って試してみたメモ。


fun cyclic(index: Int = 0): Observable<Int> = when(index) {
    in 0..5 -> Observable.concat(Observable.just(index), cyclic(index + 1))
    else -> Observable.empty()
}

cyclic().subscribe { println(it) }
=> 0
1
2
3
4
5

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0