patloew/RxFit

What happens when unsubscribing from a certain operation?

CooperRS opened this issue ยท 1 comments

Hey!

Thank you for this nice library wrapping Foogle Fit into a nice RxFit API ๐Ÿ™‚.

Given I am starting a Google Fit session using RxFit.sessions().startSession(...). Executing startSession(...) returns a Single, subscribing to that Single actually starts the process to start the Google Fit session. So far, everything is clear to me.

But starting the session is a process that may take some seconds. I was wondering what the right course of action is if the user decides to cancel in this time?

Intuitively, I would unsubscribe from the Single that has been returned by startSession(...). But would this actually cancel the Google Fit API call? Furthermore, if it cancels the Google Fit API call: Is it guaranteed, that no Google Fit Session is started? Or may canceling the operation lead to an unknown state where a Google Fit session may be started or not depending on how far Google Fit came setting up the session?

Thanks for the answers!
Roland

The GoogleApiClient is disconnected on unsubscribe. Therefore, the PendingResult is also cancelled, if it was not already successful. I can not guarantee you the exact behavior, e.g. when you unsubscribe at the same moment as the PendingResult ResultCallback is/would be called.