mavlink / MAVSDK-Java

MAVSDK client for Java.
68 stars 40 forks source link

Remove replay(1) from streams #72

Closed divyanshupundir closed 2 years ago

divyanshupundir commented 2 years ago

The replay operator is added to all the flowable streams in the library.

return flowable
  .replay(1)
  .autoConnect();

This creates certain issues while using them.

  1. It is difficult to differentiate between live events and cached ones. For example, if we subscribe to Camera.CaptureInfo at some point in time, the last data point gets sent even if the photo may have been taken 10 minutes ago.

  2. If someone is using LiveData on Android, which does its own caching, the caching on the library side further creates some unexpected behaviour.

Yes, the replay is useful under certain situations, but it requires tricky workarounds to invalidate it downstream once its added. Therefore, I feel that simply returning the flowable without the replay is good enough, and the library should let the user implement the caching on his/her own.

Any thoughts?

JonasVautherin commented 2 years ago

Sounds good to me!

divyanshupundir commented 2 years ago

Great. I'll create a PR either today or tomorrow.