What is the difference between Observable and Flowable in RxJava 2.0?

As stated in the documentation: A small regret about introducing backpressure in RxJava 0.x is that instead of having a separate base reactive class, the Observable itself was retrofitted. The main issue with backpressure is that many hot sources, such as UI events, can’t be reasonably backpressured and cause unexpected MissingBackpressureException (i.e., beginners don’t expect … Read more

What is the difference between Schedulers.io() and Schedulers.computation()

Brief introduction of RxJava schedulers. Schedulers.io() – This is used to perform non-CPU-intensive operations like making network calls, reading disc/files, database operations, etc., This maintains a pool of threads. Schedulers.newThread() – Using this, a new thread will be created each time a task is scheduled. It’s usually suggested not to use scheduler unless there is … Read more

Android Rxjava subscribe to a variable change

Nothing is magic in the life : if you update a value, your Observable won’t be notified. You have to do it by yourself. For example using a PublishSubject. public class Test extends MyChildActivity { private int VARIABLE_TO_OBSERVE = 0; Subject<Integer> mObservable = PublishSubject.create(); protected void onCreate() {/*onCreate method*/ super(); setContentView(); method(); changeVariable(); } public … Read more

How to reset a BehaviorSubject

I assume you want to clear the BehaviorSubject (because otherwise don’t call onComplete on it). That is not supported but you can achieve a similar effect by having a current value that is ignored by consumers: public static final Object EMPTY = new Object(); BehaviorSubject<Object> subject = BehaviorSubject.createDefault(EMPTY); Observable<YourType> obs = subject.filter(v -> v != … Read more