Avoiding OperatorObserveOn from calling subscriber.onNext(..) after unsu...

...bscribe().

The OperatorObserveOn operator uses a scheduler to cancel subscriptions as well
as to deliver the objects passing through it's onNext(..) in the right context.

Calling unsubscribe will schedule the actual unsubscription while not making sure
that the child subscriber will no longer receive calls to onNext(..) after
unsubscribe() returns.

This fix makes sure that after unsubscribe() returns no more onNext(..) calls will be
made on the child subscribers.

Signed-off-by: David Marques <dpsmarques@gmail.com>
To avoid the call to onNext after unsubscribe is called, you'd need an serializing emitter loop, similar to what SerializedObserver has. However, that adds more overhead.

Your case sounds like @headinthebox 's AsyncObservable where onNext returns a Future and thus can be cancelled individually.