October 2018
Intermediate to advanced
556 pages
15h 18m
English
When we build complicated reactive workflows, it is often necessary to use the same sequence of operators in a couple of different places. With the transform operator, we can extract such common pieces into separate objects and reuse them whenever required. Previously, we've transformed events within a stream. With the transform operator, we can augment the stream structure itself. Let's assume the following example:
Function<Flux<String>, Flux<String>> logUserInfo = // (1) stream -> stream // .index() // (1.1) .doOnNext(tp -> // (1.2) log.info("[{}] User: {}", tp.getT1(), tp.getT2())) // .map(Tuple2::getT2); // (1.3)Flux.range(1000, 3) // (2) .map(i -> "user-" + i) // .transform(logUserInfo) // ...