https://github.com/diffplug/durian-rx
Reactive getters, powered by RxJava and ListenableFuture
https://github.com/diffplug/durian-rx
Last synced: 3 months ago
JSON representation
Reactive getters, powered by RxJava and ListenableFuture
- Host: GitHub
- URL: https://github.com/diffplug/durian-rx
- Owner: diffplug
- License: apache-2.0
- Created: 2015-05-19T21:56:29.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2025-02-01T02:22:35.000Z (11 months ago)
- Last Synced: 2025-04-23T08:08:17.473Z (8 months ago)
- Language: Java
- Size: 1.91 MB
- Stars: 19
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
#
DurianRx: Reactive getters, powered by RxJava and ListenableFuture
[](https://search.maven.org/artifact/com.diffplug.durian/durian-rx)
[](https://tldrlegal.com/license/apache-license-2.0-(apache-2.0))
[](CHANGES.md)
[](https://javadoc.io/doc/com.diffplug.durian/durian-rx/5.1.0/)
[](https://gitter.im/diffplug/durian)
[](https://jitci.com/gh/diffplug/durian-rx)
DurianRx unifies RxJava's [Observable](http://reactivex.io/documentation/observable.html) with Guava's [ListenableFuture](https://code.google.com/p/guava-libraries/wiki/ListenableFutureExplained). If you happen to be using SWT as a widget toolkit, then you'll want to look at [DurianSwt](https://github.com/diffplug/durian-swt) as well.
```java
Observable observable = someObservable();
ListenableFuture future = someFuture();
Rx.subscribe(observable, val -> doSomething(val));
Rx.subscribe(future, val -> doSomething(val));
```
It also provides [reactive getters](src/com/diffplug/common/rx/RxGetter.java?ts=4), a simple abstraction for piping data which allows access via `T get()` or `Observable asObservable()`.
```java
RxBox mousePos = RxBox.of(new Point(0, 0));
this.addMouseListener(e -> mousePos.set(new Point(e.x, e.y)));
Rectangle hotSpot = new Rectangle(0, 0, 10, 10)
RxGetter isMouseOver = mousePos.map(hotSpot::contains);
```
Debugging an error which involves lots of callbacks can be difficult. To make this easier, DurianRx includes a [tracing capability](src/com/diffplug/common/rx/RxTracingPolicy.java?ts=4), which makes this task easier.
```java
// anytime an error is thrown in an Rx callback, the stack trace of the error
// will be wrapped by the stack trace of the original subscription
DurianPlugins.register(RxTracingPolicy.class, new LogSubscriptionTrace()).
```
DurianRx's only requirements are [durian-base, durian-collect, durian-concurrent](https://github.com/diffplug/durian), and [RxJava](https://github.com/reactivex/rxjava).
## Acknowledgements
* Many thanks to [RxJava](https://github.com/reactivex/rxjava) and [Guava](https://github.com/google/guava).
* Built by [gradle](http://gradle.org/).
* Tested by [junit](http://junit.org/).
* Maintained by [DiffPlug](http://www.diffplug.com/).