Posts

Showing posts with the label rx-java2

Why is rxJava not showing any effect of BackPressure startegy?

Image
Clash Royale CLAN TAG #URR8PPP Why is rxJava not showing any effect of BackPressure startegy? Hi I am quite naive with rxJava, so please let me know if my understanding is correct. As per my understanding if I use backpressure strategy with LATEST flag, I should be getting the most recent value. So I have a list, I am using flowable with subscriber, but it is still printing all values in onNext . Also please let me know how to test this backpressure strategy as I do not have real time data. Following is my code Observable.just(listObj).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()). flatMap(new Function<List<String>, Observable<String>>() { @Override public Observable<String> apply(List<String> ints) { return Observable.fromIterable(ints); } }).toFlowable(BackpressureStrategy.LATEST).subscribe(new Su...

onNext of a created Observable does not work

Image
Clash Royale CLAN TAG #URR8PPP onNext of a created Observable does not work I am learning how to use Observable.create(). so i created the below posted example. but when I run the App. and click the button the log statement in the onNext is never displayed. and i receive the following message: The application may be doing too much work on its main thread. please let me know how to do it the corret way. code : Observable.create(emitter -> { btnStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { emitter.onNext(Log.i(TAG, "i: " + i[0]++)); } }); }); How do you consume this Observable ? The code shown barely does anything so it is unlikely you get the warning for this piece of code. – akarnokd 44 secs ago Observable ...