Remora Bindings

Remora Bindings is a Java library that offers two-way data bindings that glue UI widgets to data sources. Contrary to most other binding APIs, Remora Bindings does not offer any built-in change notification or reactivity and instead relies on transparent reactivity offered by libraries like Hookless.

Download

Get Remora Bindings from Maven Central:

Maven tool
<dependency>
    <groupId>com.machinezoo.remorabindings</groupId>
    <artifactId>remorabindings</artifactId>
    <version>0.2.2</version>
</dependency>

Or clone sources from GitHub or Bitbucket. Don't forget to configure your build for Java 17+. Sources and binaries are distributed under Apache License 2.0.

If your project is a Java module, add the following declaration to your module-info.java:

requires com.machinezoo.remorabindings;

Usage

At its core, binding is just an interface with two methods: get() and set(). You can bind to anything, but in this simple example, we will bind to a Map:

record Key(String name, int id) {}
var map = new HashMap<Key, String>();
var binding = OptionalStringBinding.bind(map, new Key("xyz", 123));
System.out.println(binding.get());
binding.set(Optional.of("abc"));
System.out.println(binding.get());

The above code should produce this output:

Optional.empty
Optional[abc]

There are many kinds of bindings that can be transformed in many ways. See current source code. There are some built-in binding sources (other than Map). See ReactivePreferencesBindings and SiteFragmentBindings.

Next steps