Why is rxJava not showing any effect of BackPressure startegy?

The name of the pictureThe name of the pictureThe name of the pictureClash 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 Subscriber<String>() {
@Override
public void onSubscribe(Subscription s) {
s.request(Long.MAX_VALUE);
}

@Override
public void onNext(String s) {
Log.d("Value", s);
}

@Override
public void onError(Throwable t) {

}

@Override
public void onComplete() {

}
});
}



///////////
Following is s simple method which creates arraylist


private ArrayList<String> createListForReturn() {
try {
if (listObj != null) {
listObj.add("Thanks");
listObj.add("fine");
listObj.add("working");
listObj.add("is");
listObj.add("Flowable");
listObj.add("Now");
listObj.add("Flowable");
listObj.add("For");
listObj.add("Programme");
listObj.add("RxJava");
listObj.add("Second");
listObj.add("My");
listObj.add("is");
listObj.add("This");
listObj.add(" ");
}
return listObj;

} catch (Exception e) {

e.printStackTrace();
return null;
}
}





"BackPressure Strategy" in Rx means "If you can't consume the onNext events quicker than upstream can feed them, what do you want to do. In your case you are consuming all events quickly enough.
– Mark Keen
33 secs ago




onNext









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

'Series' object is not callable Error / Statsmodels illegal variable name