toMap

fun <T, K> Observable<T>.toMap(keySelector: (T) -> K): Single<Map<K, T>>

Returns a Single that emits a Map containing all elements emitted by the finite source Observable, associated with keys returned by keySelector.

⚠️ Warning: if the emitted Map becomes frozen somewhere in the downstream in Kotlin/Native, then the operator will copy the Map on next iteration, which can significantly affect performance.

Please refer to the corresponding RxJava document.


fun <T, K, V> Observable<T>.toMap(keySelector: (T) -> K, valueSelector: (T) -> V): Single<Map<K, V>>

Returns a Single that emits a Map containing all elements emitted by the finite source Observable, transformed by valueSelector and associated with keys returned by keySelector.

⚠️ Warning: if the emitted Map becomes frozen somewhere in the downstream in Kotlin/Native, then the operator will copy the Map on next iteration, which can significantly affect performance.

Please refer to the corresponding RxJava document.