Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RxJava "serialize" method use cases

Tags:

java

rx-java2

I want to know cases in which we need to "serialize" observable, its necessary. I mean cases in which "onNext" method will get called concurrently instead of one after another.

like image 871
Ashutosh Jha Avatar asked Mar 31 '17 18:03

Ashutosh Jha


1 Answers

Originally, serialize() was introduced to fix some badly behaving custom Observables from the consumer's end instead of making the author fix his create()-ion in 1.x. As the enforcing of the Observable protocol became more prominent, there was less need for the operator in practice. It still ended up in v2 just in case and for "nostalgic reasons". Note that its sibling, Subject.toSerialized() is completely legitimate and is there to serialize access to a Subject in case it is driven from multiple threads.

like image 141
akarnokd Avatar answered Sep 29 '22 01:09

akarnokd