Git Product home page Git Product logo

cyclops's Introduction

screen shot 2016-02-22 at 8 44 42 pm

Documentation

The cyclops-react integration modules.

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)

Integration module features

  1. reactive-streams support
  2. for-comprehensions
  3. type conversion
  4. AnyM, AnyMValue and AnyMSeq support
  5. Lazy Extended Collections (via cyclops-reactor)
  6. Utilities for connecting Streams (cyclops-reactor Flux types) in advanced ways
  7. Utilities for pushing data into Streams (e.g. cyclops-reactor Flux types)

Reactive Streams support and AnyM 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.

Examples

Convert a Javaslang List into a reactive-stream
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);
Schedule emission from FunctionalJava Stream
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.

for-comprehensions

All cyclops integration modules offer full strength for-comprehensions, allowing for example a Javaslang Stream generator to access each element in a preceeding Stream.

Examples

Working with Pivotal Reactor Fluxes
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);
Programming 'monadically' with FunctionalJava Writer's
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"												

type conversions

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).

Getting cyclops-react

  • Maven Central : cyclops-react

Gradle

where x.y.z represents the latest version

compile 'com.aol.simplereact:cyclops-react:x.y.z'

Maven

<dependency>
    <groupId>com.aol.simplereact</groupId>
    <artifactId>cyclops-react</artifactId>
    <version>x.y.z</version>
</dependency>

cyclops's People

Contributors

awturner avatar bigkahuna1uk avatar c0nscience avatar earlzero avatar gitter-badger avatar greg2001 avatar h3xstream avatar jbgi avatar johnmcclean avatar lukaseder avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.