These are chat archives for ReactiveX/RxJava

20th
Jun 2017
Nayshawn Danner
@NayshawnD_twitter
Jun 20 2017 14:25
Hi all,
Nayshawn Danner
@NayshawnD_twitter
Jun 20 2017 14:31
whoops!, was wonder if this was some how possible in RxJava:
Subject<Integer, String> publishSubject = PublishSubject.create()
PublishSubject<T, T> obviously doesn't like to type transformation, even though the Subject type suggest that this could be possible. Suggestions any one?
Sourabh Verma
@sourabhv
Jun 20 2017 17:04

Is there a way to make requests in parellel in batch. Like, if I have a list of ids and I want to get details of those ids 4 at a time. This is what I have till now

api.users().flatMap(Observable::fromIterable)
                .buffer(4)
                .flatMap(users -> Observable.fromIterable(users).flatMap(user -> api.usersData(user.username).subscribeOn(Schedulers.newThread())))
                .subscribe(user -> System.out.println(user.toStringNew()), Throwable::printStackTrace);

but this thing makes all requests in parellel, not in batches of 4

Stergio
@stergiom
Jun 20 2017 17:05
perhaps try using a fixed size threadpool in place of Schedulers.newThread
Sourabh Verma
@sourabhv
Jun 20 2017 17:06
But is there a better way instead of depending on size of theadpool
Stergio
@stergiom
Jun 20 2017 17:07
there is the flatMap(func, maxConcurrency) overload