I use this observable to set my UI.The problem is as such. the observable obtained from getName() is non-completing. When my fragment is paused/stopped ,I clear my CompositeSubscription and add all the subscribers again.This results in the last item of the observable to be reemitted.I use the getName observable as a part of a click listener too. i.e.:

As such on every pause/resume cycle,sendEmailInternal gets trigerred because of the value emitted.I understand this is how a BehaviourSubject well..behaves. But is there any way I can make sure that I can limit sendEmail() only to a click(i.e. one value emitted) and not continous changes to the observable.

@droidekas Yeah, first of all, do not nest subscribe calls. If you solve that you probably have half the problem out of the way.

Second do not abuse filter for side effects. Use do

Third if you shouldn't need to track all your subscribers all day. You can also make a subscription that is on hold when the source is inactive, but you can also make one that unsubscribes itself when a certain condition is met. Like with takeWhile or takeUntil.

Fourth if you need to trigger emails only on click, the source should be the click event and nothing else. You can do something like clickEvent.withLatestFrom(otherSource)