public static < T , R > Observable < List < R > > batchToStream ( final List < T > elements , final int batchSize , final FutureSuccessHandler < T , R > producer ) { return Observable . create ( subscriber -> batchToStream ( elements , batchSize , 0 , subscriber , producer ) ) ; }
Execute the producer on each element in the list in batches and return a stream of batch results . Every batch is executed in parallel and the next batch begins only after the previous one ended . The result of each batch is the next element in the stream . An error in one of the futures produced by the producer will end the stream with the error