Skip to content

Instantly share code, notes, and snippets.

@hkurokawa
Created August 24, 2017 10:00
Show Gist options
  • Save hkurokawa/aed6e97bbcfffd6ee14df22a09339548 to your computer and use it in GitHub Desktop.
Save hkurokawa/aed6e97bbcfffd6ee14df22a09339548 to your computer and use it in GitHub Desktop.
import io.reactivex.Maybe;
import io.reactivex.Single;
import org.junit.Test;
public class SingleTest {
@Test public void testSingleConcat() {
Single<String> localSource = Single.create(emitter -> {
emitter.onError(new RuntimeException("1個目のError"));
});
Single<String> remoteSource = Single.create(emitter -> {
emitter.onError(new RuntimeException("2個目のError"));
});
Maybe.concat(localSource.toMaybe().onErrorComplete(), remoteSource.toMaybe())
.firstOrError()
.subscribe(System.out::println, System.err::println);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment