Based on ReactiveX documentation
the from operator can convert a Future, an Iterable, or an Array. In the case of an Iterable or an Array, the resulting Observable will emit each item contained in the Iterable or Array.
we can have an observable from an Array
or List
and observable emits the items in the list.
I have a HashMap<String,Item>
and i want to iterate through the items just like making an observable with Observable.from(List<Item>)
.
In other words, i want the observable to emit HashMap Items
.
Is there a solution to do this?
You can make the map entries into an Observable like this:
Observable<Entry<String, Item>> entries =
Observable.from(map.entrySet());
If you just want the values from the map:
Observable<Item> items = Observable.from(map.values());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With