RxJava 3 interop library for supporting Java 9 features such as Flow.


License

License

Categories

Categories

RxJava Container Microservices Reactive libraries
GroupId

GroupId

com.github.akarnokd
ArtifactId

ArtifactId

rxjava3-jdk9-interop
Last Version

Last Version

3.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

RxJava 3 interop library for supporting Java 9 features such as Flow.
RxJava 3 interop library for supporting Java 9 features such as Flow.
Project URL

Project URL

https://github.com/akarnokd/RxJavaJdk9Interop
Source Code Management

Source Code Management

https://github.com/akarnokd/RxJavaJdk9Interop

Download rxjava3-jdk9-interop

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.akarnokd/rxjava3-jdk9-interop/ -->
<dependency>
    <groupId>com.github.akarnokd</groupId>
    <artifactId>rxjava3-jdk9-interop</artifactId>
    <version>3.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.akarnokd/rxjava3-jdk9-interop/
implementation 'com.github.akarnokd:rxjava3-jdk9-interop:3.0.0'
// https://jarcasting.com/artifacts/com.github.akarnokd/rxjava3-jdk9-interop/
implementation ("com.github.akarnokd:rxjava3-jdk9-interop:3.0.0")
'com.github.akarnokd:rxjava3-jdk9-interop:jar:3.0.0'
<dependency org="com.github.akarnokd" name="rxjava3-jdk9-interop" rev="3.0.0">
  <artifact name="rxjava3-jdk9-interop" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.akarnokd', module='rxjava3-jdk9-interop', version='3.0.0')
)
libraryDependencies += "com.github.akarnokd" % "rxjava3-jdk9-interop" % "3.0.0"
[com.github.akarnokd/rxjava3-jdk9-interop "3.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
io.reactivex.rxjava3 : rxjava jar 3.0.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

RxJavaJdk9Interop

codecov.io Maven Central

RxJava 3 interop library for supporting Java 9 features such as Flow.*

Release

compile 'com.github.akarnokd:rxjava3-jdk9-interop:3.0.0'

Examples

Converting from RxJava 3 to Java 9 Flow

import hu.akarnokd.rxjava3.jdk9interop.*;

Flow.Publisher<Integer> pub = Flowable.range(1, 5)
    .to(FlowInterop.toFlow());

// --------

Flow.Processor<Integer, Integer> proc = FlowInterop
    .toFlowProcessor(PublishProcessor.create()); 

Converting from Java 9 Flow to RxJava 3

SubmissionPublisher<Integer> sp = new SubmissionPublisher<>();

Flowable<Integer> f = FlowInterop
    .fromFlowPublisher(sp);

// --------

Flow.Processor<Integer, Integer> fp = ...

FlowableProcessor<Integer> fproc = FlowInterop
    .fromFlowProcessor(fp);

Note that RxJava 3 FlowableProcessors don't support different input and output types therefore the Flow.Processor should have the same type arguments.

For convenience, there is a FlowTestSubscriber that extends TestSubscriber and allows asserting on a Flow.Publisher the same way as with Reactive-Streams Publisher types.

FlowTestSubscriber<Integer> ts = new FlowTestSubscriber<>();

SubmissionPublisher<Integer> sp = new SubmissionPublisher<>();

sp.subscribe(ts);

sp.onNext(1);
sp.onNext(2);
sp.onNext(3);
sp.onNext(4);
sp.onNext(5);
sp.close();

ts.awaitDone(5, TimeUnit.SECONDS) // SubmissionPublisher is async by default
  .assertResult(1, 2, 3, 4, 5);

Versions

Version
3.0.0
3.0.0-RC8
3.0.0-RC7
3.0.0-RC6
3.0.0-RC5
3.0.0-RC4
3.0.0-RC3
3.0.0-RC2
3.0.0-RC1