question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Observable<List<X>> to Observable<X> that emits each element in List<X>

See original GitHub issue

Is there a utility operator for converting from Observable<List<X>> to an Observable<X> that emits each element in List<X>?

Otherwise, are there any obvious optimizations for something like:

getChannels().switchMap(channels -> Observable.from(channels))

flatMap() could be used as well, depending.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:9
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

48reactions
andreathackercommented, Apr 12, 2017

For anyone else who comes across this thread, I think that flatMapIterable will do the trick. You should be able to call .listObservable.flatMapIterable(items -> items) and get a stream of the items from the list that way.

11reactions
zsxwingcommented, Jan 21, 2015

You can also use flatMapIterable like getChannels().flatMapIterable(l -> l).

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - RxJava - fetch every item on the list - Stack Overflow
Observable.flatMapIterable: Returns an Observable that merges each item emitted by the source ObservableSource with the values in an Iterable ...
Read more >
Observable - RxJS
RxJS introduces Observables, a new Push system for JavaScript. An Observable is a Producer of multiple values, "pushing" them to Observers (Consumers). A ......
Read more >
Just operator - ReactiveX
The Just operator converts an item into an Observable that emits that item. Just is similar to From, but note that From will...
Read more >
ObservableList (JavaFX 8) - Oracle Help Center
A convenient method for var-arg adding of elements. void, addListener(ListChangeListener<? super E> listener). Add a listener to this observable list.
Read more >
Observable - Monix
_ // We first build an observable that emits a tick per second, // the series of ... fromIterable(List(1, 2, 3)) // obs:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found