Maciek
09/23/2019, 12:21 PMonNext on subject. Can someone explain why `subscribe`method on observable where you pass whole subject object is not working the same way? Also what is happening with disposable from such subscribe? Is it the same disposable when you make subscription on the subject?arekolek
09/23/2019, 12:37 PMobservable.subscribe(subject) will forward onComplete to the subject as well [1], and to quote David Karnok: “When a BehaviorProcessor is terminated, the cached value is no longer available to late Subscribers.” [2]
[1] https://github.com/JakeWharton/RxRelay
[2] https://stackoverflow.com/questions/47982511/test-that-rxjava-behaviorprocessor-emits-a-valuearekolek
09/23/2019, 12:39 PMobservable.subscribe(subject::onNext) (like you did in first example), or use a Relay and observable.subscribe(relay) will work as you expect (which is still like the first example, because it implements Consumer)Maciek
09/23/2019, 1:27 PMRelay is working as expected, but it actually uses the same method as lambda subscribe. It's the one with the Consumer, when you're calling subscribe with normal subject it's using overload with Observer which is few methods down the line after subscribe with Consumer. Difference is still that subscribe from subject won't return disposable and from relay and lambda will.