Skip to content
johnmcclean-aol edited this page Nov 22, 2016 · 10 revisions

For

The For class in cyclops-react provides For comprehensions for Publishers, Values and access to the lower level Do builder for other types (iterable, reader, future, optional, Stream anyM).

## Examples

Example : Flux, ReactiveSeq, Maybe and Mono via For.Publishers

With For.Publishers we can execute For comprehensions, that perform nested loops over any Publisher type.

import org.jooq.lambda.tuple.Tuple;
import org.jooq.lambda.tuple.Tuple4;
import static com.aol.cyclops.control.For.Publishers.each4;
ListX<Tuple4<Integer,Integer,Integer,Integer>>  list = each4(Flux.range(1,10), 
                                                             a-> ReactiveSeq.iterate(a,i->i+1).limit(10),
                                                             (a,b) -> Maybe.<Integer>of(a+b),
                                                             (a,b,c) -> Mono.<Integer>just(a+b+c),
                                                             Tuple::tuple)
                                                             .toListX();

Clone this wiki locally