You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
johnmcclean-aol edited this page Dec 6, 2016
·
1 revision
forEach operators
cyclops-react types (Eval, Maybe, [FutureW](FutureW], Xor, Ior, Try, FeatureToggle, Either1-5, ListX, DequeX, SetX, SortedSetX, PStackX, PVectorX, POrderedSetX, PQueueX, PBagX, AnyMValue, AnyMSeq, LazyFutureStream, ReactiveSeq) all have in built native for comprehension operators forEach2-4.
For comprehensions simplify nested flatMap operations. forEach operators accept 2-4 additional functions (for forEach2-4) which are then applied in nested fashion via flatMap and map.
E.g. this nested set of operations on a Maybe could be rewritten
Maybe.just(2)
.flatMap(n->loadById(n).map(r->n*r))
//if loadById returns 3 we get Maybe[6]