Monday, 2 February 2015

SimpleReact : Simple Functional Reactive Programming for Java 8

We (the very productive and small team I work with here in Aol) have just released a very lightweight functional reactive programming library for Java 8. It builds entirely on pre-existing JDK 8 libraries (so functional interfaces, Streams, CompletableFuture) and makes it very easy to create asynchronous reactive dataflows.

Getting started

Getting started is as simple as setting up a basic Reactive flow such as the following and evolving from there -
 List<String> strings = new SimpleReact()
            .<Integer> react(() -> 1, () -> 2, () -> 3)
            .then(it -> it * 100)
            .then(it -> "*" + it)
            .block();

This will result in a list, that looks something like this :
 ["*100","*200","*300"]

Although not necessarily in that order. All the work will be done asynchronously, and the block() method blocks the current thread until all the work is complete (& blocking the current thread is optional). See more examples on the SimpleReact wiki .

Adding SimpleReact as a dependency


SimpleReact is available on Maven Central.

Gradle


compile group: 'com.aol.simplereact', name:'simple-react', version:'0.1'

Gradle


<dependency>
 <groupId>com.aol.simplereact</groupId>
  <artifactId>simple-react</artifactId>
  <version>0.1</version>
  <scope>compile</scope>
</dependency>
 

No comments:

Post a Comment