-
Notifications
You must be signed in to change notification settings - Fork 134
For
johnmcclean-aol edited this page Nov 22, 2016
·
10 revisions
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
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();oops - my bad