Convert observable to list

Khanh Nguyen picture Khanh Nguyen · Oct 11, 2014 · Viewed 36.5k times · Source

I am using RxJava.

I have an Observable<T>. How do I convert it to List<T>?

Seems to be a simple operation, but I couldn't find it anywhere on the net.

Answer

diduknow picture diduknow · Oct 12, 2014

Hope this helps.

List<T> myList = myObservable.toList().toBlocking().single();

thanks

anand raman