Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Suganthan Madhavan Pillai msuganthan

🎯
Focusing
View GitHub Profile
View Some Rx-Java
List<Set<String>> sets = Observable.fromIterable(searchResults)
.flatMap(searchResult -> Observable.just(searchResult))
.subscribeOn(Schedulers.io())
.map(link -> pageInspector.inspect(link, TIMEOUT))
.toList()
.blockingGet();
Map<String, Long> collect = sets.stream()
.flatMap(Set::stream)
.collect(groupingBy(Function.identity(), counting()));
View RxJava- Achieving Parallelization
public static void main(String[] args) throws Exception{
Observable<Integer> vals = Observable.range(1,100);
vals.flatMap(val -> Observable.just(val)
.subscribeOn(Schedulers.computation())
.map(i -> intenseCalculation(i))
).toList().subscribe(val -> System.out.println("Subscriber received "
+ val + " on "
+ Thread.currentThread().getName()));
}
You can’t perform that action at this time.