ReactiveX / RxAndroid

RxJava bindings for Android
Apache License 2.0
19.89k stars 2.94k forks source link

toMap for Arraymap #359

Closed kagile closed 7 years ago

kagile commented 7 years ago

Is there any way to create ArrayMap instead of HashMap using toMap() in RxJava or RxAndroid?

JakeWharton commented 7 years ago

This is a question for RxJava, not RxAndroid. The answer will be that you need to implement it yourself though, because there's no map factory abstraction in RxJava.

dimsuz commented 7 years ago

I remember that I used collect() operator for this, something like

observable.collect(() -> new ArrayMap<K,V>(), (map, v) -> map.put(toKey(v), toValue(v))

(you decide what toKey(), toValue() do)

kagile commented 7 years ago

@dimsuz thanks. collect() works fine.