There are a number of integration modules for cyclops-react, they are
This screencast gives an overview of how cyclops can help integrate and provide abstractions across the datatypes in the above libraries. [Unifying the cambrian explosion with cyclops-react ] (https://www.youtube.com/watch?v=YgzvpMbxiRo)
- reactive-streams support
- for-comprehensions
- type conversion
- AnyM, AnyMValue and AnyMSeq support
Closely linked to cyclops-react AnyM functionality, the integration modules allow appropriate types from FunctionalJava, Javaslang, Guava, RxJava and Reactor to be wrapped in an 'AnyM' wrapper. The AnyM wrappers all act as reactive-streams publishers. So if you would like a Javaslang Array or FunctionalJava Writer or List to behave as a reactive-streams publisher, simply call the appropriate method in our Javaslang or FJ class and subscribe to the returned AnyM type.
import static com.aol.cyclops.javaslang.Javaslang.traversable;
SeqSubscriber<Integer> sub = SeqSubscriber.subscriber();
traversable(List.of(1,2,3)).subscribe(sub);
sub.stream()
.forEachWithError(System.out::println, System.err::println);
import static com.aol.cyclops.functionaljava.FJ.stream;
stream(Stream.stream(1,2,3)).schedule("* * * * * ?", Executors.newScheduledThreadPool(1))
.connect()
.forEach(System.out::println)
Cyclops AnyM and AnyMValue / AnyMSeq interfaces allow any 'monad' type (a type with map / flatMap methods like JDK 8 Streams) to be wrapped and manipulated via a common interface.
AnyMValue represents monads such as Optional, CompletableFuture, Eval (cyclops-react), Either, Try, Writer, Reader etc that resolve to a single value.
AnyMSeq represents monads such as List, Stream, Array, Set etc that resolve to a sequence of values.
All cyclops integration modules offer full strength for-comprehensions, allowing for example a Javaslang Stream generator to access each element in a preceeding Stream.
import static com.aol.cyclops.reactor.Reactor.ForFlux;
Flux<Tuple2<Integer,Integer>> stream = ForFlux.each2(Flux.range(1,10), i->Flux.range(i, 10), Tuple::tuple);
import static com.aol.cyclops.functionaljava.FJ.ForWriter;
Writer<String,String> writer = ForWriter.each2(Writer.unit("lower", "", Monoid.stringMonoid),
a->Writer.unit(a+"hello",Monoid.stringMonoid),(a,b)->a.toUpperCase() + b);
writer.value(); //"LOWERlowerhello"
cyclops integration modules support conversion between FunctionalJava, Guava, Javaslang and JDK types. (Observables, Flux, Mono from RxJava and Reactor can be converted via AnyM/ reactive-streams support or by iterables where supported).
where x.y.z represents the latest version
compile 'com.aol.simplereact:cyclops-react:x.y.z'
<dependency>
<groupId>com.aol.simplereact</groupId>
<artifactId>cyclops-react</artifactId>
<version>x.y.z</version>
</dependency>