-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
@headinthebox and I were working on some code and found differences in behavior between Rx.Net and RxJava with observeOn. This commit should fix that.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
import org.junit.Test; | ||
import org.mockito.InOrder; | ||
|
@@ -33,6 +34,8 @@ | |
import rx.Subscription; | ||
import rx.concurrency.ImmediateScheduler; | ||
import rx.concurrency.Schedulers; | ||
import rx.subscriptions.CompositeSubscription; | ||
import rx.util.functions.Func2; | ||
|
||
/** | ||
* Asynchronously notify Observers on the specified Scheduler. | ||
|
@@ -60,7 +63,9 @@ public Subscription onSubscribe(final Observer<? super T> observer) { | |
// do nothing if we request ImmediateScheduler so we don't invoke overhead | ||
return source.subscribe(observer); | ||
} else { | ||
return source.subscribe(new ScheduledObserver<T>(observer, scheduler)); | ||
CompositeSubscription s = new CompositeSubscription(); | ||
s.add(source.subscribe(new ScheduledObserver<T>(s, observer, scheduler))); | ||
return s; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
benjchristensen
Author
Member
|
||
} | ||
} | ||
} | ||
|
@benjchristensen Do you remember why you made this change? What's the value of wrapping a single subscription in a
CompositeSubscription
?