Foggy day
Android(Kotlin) - RxKotlin -2 : Map, flatMap 본문
val intSrc = Observable.just(1, 2, 3)
intSrc.subscribe(::println)
val strSrc = intSrc.map { value -> value * 10 }
strSrc.subscribe(::println)
val src = Observable.just("A", "B", "C", "D")
src.flatMap { s -> Observable.just(s + 2, s + 3) }
src.subscribe(::println)
val flatMap = Observable.range(2, 3).flatMap { x ->
Observable.range(1, 9).map { y ->
String.format("%d*%d=%d", x, y, x * y)
}
}
flatMap.subscribe(::println)
// Observable.range(2, 8).flatMap { x ->
// Observable.range(1, 9).map { y ->
// String.format("%d*%d=%d", x, y, x * y)
// }
// }.subscribe(::println)
'Android' 카테고리의 다른 글
Android(Kotlin) - Setting the viewpager2 height according to the height of the items (0) | 2021.04.18 |
---|---|
Android - screen flickering whilefragment transaction (0) | 2021.04.03 |
Android(Kotlin) - RxKotlin -2 : Observable (0) | 2021.03.23 |
Android(Kotlin) - RxKotlin -1 : PublishSubject (0) | 2021.03.23 |
Android - getSupportFragmentManager, getChildFragmentManager (0) | 2021.03.21 |