rx java - Convert one type of list to another RXJava? (Javascript map equivalent) -
lets have observable observable<list<a>>
, want convert observable observable<list<b>>
. there best possible way convert list<a>
list<b>
. javascript's map
's implementation ideal situation.
you can use observable.from(iterable<a>)
observable<a>
, map (a => b), , convert list<b>
observable.tolist()
observable.from(arrays.aslist(1, 2, 3)) .map(val -> mapinttostring(val)).tolist()
e.g.
observable.from(arrays.aslist(1, 2, 3)) .map(val -> val + "mapped").tolist() .toblocking().subscribe(system.out::println);
yields
[1mapped, 2mapped, 3mapped]
Comments
Post a Comment