Home - advantageous/reakt GitHub Wiki

reakt

Reactive interfaces for Java. Reakt website

Reakt is reactive interfaces for Java:

  • Promise,
  • Stream,
  • Callback,
  • Async Results (Result, StreamResult)

The emphasis is on defining interfaces that enable lambda expressions, and fluent APIs for asynchronous programming for Java. We briefly cover some examples and refer you to the code base for the rest.

Note: This mostly just provides the interfaces not the implementations. There are some starter implementations but the idea is that anyone can implement this. It is all about interfaces. There will be adapters for Vertx, RxJava, Reactive Streams, Guava Async Futures, etc.

Fluent Promise API

  Promise<Employee> promise = promise()
                .then(e -> saveEmployee(e))
                .catchError(error -> 
                     logger.error("Unable to lookup employee", error));

  employeeService.lookupEmployee(33, promise);

Or you can handle it in one line.

Fluent Promise API example 2

  employeeService.lookupEmployee(33, 
        promise().then(e -> saveEmployee(e))
                 .catchError(error -> logger.error(
                                           "Unable to lookup ", error))
        );

Promises are both a callback and a Result; however, you can work with Callbacks directly.

Using Result and callback directly

        employeeService.lookupEmployee(33, result -> {
            result.then(e -> saveEmployee(e))
                  .catchError(error -> {
                    logger.error("Unable to lookup", error);
            });
        });

In both of these examples, lookupEmployee would look like:

Using Result and callback directly

   public void lookupEmployee(long employeeId, Callback<Employee> callback){...}

QBit version 2 is going to use Reakt. Connekt, a slimmed down fork of Vert.x, will also use Reakt.

See QBit microservices lib for more details.

See our wiki for more details on Reakt.

⚠️ **GitHub.com Fallback** ⚠️