java - RxJava- performing a peek() or void operation within an Observable chain? -


java 8 lambda streams have peek() operator allows execute void operation on each item. typically used debugging, nice way cheat , kick off void operation without mapping something.

is there equivalent in rxjava? maybe i'm not following practice or thinking reactively enough... handy create status labels before , after operation? if peek() not supported, there better pattern follow?

observable<item> item= ...;  label statuslabel = new label(); label resultlabel = new label();  observable<calculateditem> calculateditem = calculated.subscribeon(schedulers.computation()) .peek(c -> statuslabel.settext("working..")) .map(c -> performexpensivecalculation(c)) .peek(r -> statuslabel.settext(""));  calculateditem.subscribe(c -> resultlabel.settext(c)); 

there method doonnext(action1<item> action) called each item in stream.

documentation


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -