mavlink / MAVSDK-Java

MAVSDK client for Java.
71 stars 41 forks source link

sdk: share streams between callers #4

Closed JonasVautherin closed 5 years ago

JonasVautherin commented 5 years ago

@RyanHurst: Would you mind reviewing this PR by testing if this solves your problem before I merge?

It may not be super easy to read in the templates, but I essentially to the following:

  1. Save the flowables as members, so that calls like telemetry.armed() always get the same object (before it was creating a new one everytime, registering a new callback to the C++ SDK).

  2. Use RxJava2's replay and autoConnect operators to "share" the subscription between all the subscribers of that shared object, with:

.replay(1)
.autoConnect();

Resolves #3.