I need to show a progress dialog when I subscribe to a Completable
and hide it after the operation is completed(successfully or with an error) or is canceled.
So I do
final Completable completable = notificationRepository.markAllAsRead()
.doOnSubscribe(d -> progressDialog.show())
.doOnError(error -> progressDialog.dismiss())
.doOnComplete(() -> progressDialog.dismiss())
.doOnDispose(() -> progressDialog.dismiss());
Is there any elegant way to get single callback when
onError
, onComplete
or onDispose
happens?