Java Code Examples for reactor.core.publisher.Flux#zipWith()
The following examples show how to use
reactor.core.publisher.Flux#zipWith() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: reactor-workshop File: R043_Zip.java License: GNU General Public License v3.0 | 6 votes |
@Test public void errorBreaksZip() throws Exception { //given final Flux<Integer> nums = Flux.just(1, 2, 3); final Flux<String> strs = Flux.concat( Flux.just("a", "b"), Flux.error(new RuntimeException("Opps")) ); //when final Flux<Tuple2<Integer, String>> pairs = nums.zipWith(strs); //then pairs .as(StepVerifier::create) .expectNext(Tuples.of(1, "a")) .expectNext(Tuples.of(2, "b")) .verifyErrorMatches(e -> e.getMessage().equals("Opps")); }
Example 2
Source Project: reactor-workshop File: R043_Zip.java License: GNU General Public License v3.0 | 5 votes |
@Test public void zipTwoStreams() throws Exception { //given final Flux<Integer> nums = Flux.just(1, 2, 3); final Flux<String> strs = Flux.just("a", "b"); //when final Flux<Tuple2<Integer, String>> pairs = nums.zipWith(strs); final Flux<Tuple2<Integer, String>> pairs2 = Flux.zip(nums, strs); //same thing //then pairs.subscribe(p -> log.info("Pair: {}", p)); }
Example 3
Source Project: cyclops File: FluxAdapter.java License: Apache License 2.0 | 5 votes |
@Override public <T, R> AnyM<flux, R> ap(AnyM<flux,? extends Function<? super T,? extends R>> fn, AnyM<flux, T> apply) { Flux<T> f = stream(apply); Flux<? extends Function<? super T, ? extends R>> fnF = stream(fn); Flux<R> res = fnF.zipWith(f, (a, b) -> a.apply(b)); return FluxAnyM.anyM(res); }