rx-java

Buffer Operator on Java 8 Streams

帅比萌擦擦* 提交于 2020-12-07 05:02:55
问题 I am trying to write a java 8 stream collector which mirrors the functionality of rxjava buffer operator I have a working code for this: // This will gather numbers 1 to 13 and combine them in groups of // three while preserving the order even if its a parallel stream. final List<List<String>> triads = IntStream.range(1, 14) .parallel() .boxed() .map(Object::toString) .collect(ArrayList::new, accumulator, combiner); System.out.println(triads.toString()) The accumulator here is this: final

Buffer Operator on Java 8 Streams

徘徊边缘 提交于 2020-12-07 05:01:31
问题 I am trying to write a java 8 stream collector which mirrors the functionality of rxjava buffer operator I have a working code for this: // This will gather numbers 1 to 13 and combine them in groups of // three while preserving the order even if its a parallel stream. final List<List<String>> triads = IntStream.range(1, 14) .parallel() .boxed() .map(Object::toString) .collect(ArrayList::new, accumulator, combiner); System.out.println(triads.toString()) The accumulator here is this: final

Buffer Operator on Java 8 Streams

北城以北 提交于 2020-12-07 05:01:19
问题 I am trying to write a java 8 stream collector which mirrors the functionality of rxjava buffer operator I have a working code for this: // This will gather numbers 1 to 13 and combine them in groups of // three while preserving the order even if its a parallel stream. final List<List<String>> triads = IntStream.range(1, 14) .parallel() .boxed() .map(Object::toString) .collect(ArrayList::new, accumulator, combiner); System.out.println(triads.toString()) The accumulator here is this: final

flatZip in RxJava

China☆狼群 提交于 2020-12-02 07:13:30
问题 I'm zipping multiple Observables together and then transforming them in a way that results in an Observable: final Observable<Observable<M>> result = Observable.zip(obs1, obs2, transformFunc); What I'd like to be able to do is: final Observable<M> result = Observable.flatZip(obs1, obs2, transformFunc); What's the cleanest way to do this, given flatZip doesn't exist (maybe I should submit one). At the moment I'm having to flatMap the result in on itself. 回答1: public class RxHelper { public

Kotlin sealed class subclass needs to be casted to base class if provided as RxJava Observable

爷,独闯天下 提交于 2020-11-28 04:47:12
问题 I'm trying to avoid terminal states of RxJava chains in my app written in Kotlin, so I found out that it is right thing to transform Observable<T> to Observable<Result<T>> where Result is sealed class. sealed class Result<T> data class Success<T>(val data: T) : Result<T>() data class Failure<T>(val throwable: Throwable) : Result<T>() And let's say I have this network request observable. fun getOrganization(): Observable<Result<Boolean>> { return api.getOrganization("google") .map { Success

Kotlin sealed class subclass needs to be casted to base class if provided as RxJava Observable

↘锁芯ラ 提交于 2020-11-28 04:47:08
问题 I'm trying to avoid terminal states of RxJava chains in my app written in Kotlin, so I found out that it is right thing to transform Observable<T> to Observable<Result<T>> where Result is sealed class. sealed class Result<T> data class Success<T>(val data: T) : Result<T>() data class Failure<T>(val throwable: Throwable) : Result<T>() And let's say I have this network request observable. fun getOrganization(): Observable<Result<Boolean>> { return api.getOrganization("google") .map { Success