bangarharshit/Rx-Error-Prone

Address the issues mentioned in https://speakerdeck.com/dlew/common-rxjava-mistakes

bangarharshit opened this issue · 2 comments

Address the issues mentioned in https://speakerdeck.com/dlew/common-rxjava-mistakes

Rx1

o1.subscribe(subcriber);
o2.subscribe(subscriber);

Subject checks for both Rx1 and Rx2:

o1.subscribe(subject);
o2.subscribe(subject); //Incorrect for non-serialized subjects as others are not thread safe. - https://artemzin.com/blog/rxjava-thread-safety-of-operators-and-subjects/

subject.onNext("dfdf") // Thread safety.

Multiple subscribeOn

Observable.just(1).subscribeOn("1).subscribeOn("2")

Also, the following example is equally problematic as subclasses of an observer can be stateful. The best case is to never allow multiple subscriptions with the same observer or consumer.

o1.subscribe(observer);
o2.subscribe(observer);