I'm working on a bluetooth project that uses RxAndroidBle for bluetooth communication. I came across two different ways that the subscriptions are cleaned up. I was wondering if anyone could explain the differences and benefits of each if there are any. The two examples are as follows.
First: using a PublishSubject
to trigger a disconnect with the bluetooth device
Second: disconnecting with the bluetooth device by unsubscribing from the Subscription
My main focus is on the triggerDisconnect()
methods in each of the examples. In what ways is the PublishSubject
way different from just keeping a reference to the Subscription
and then unsubscribing?
I do apologize for how open ended this question is but I'm not sure how better to explain it.