Java Code Examples for io.reactivex.Observable.zipWith()

The following are Jave code examples for showing how to use zipWith() of the io.reactivex.Observable class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: reactive-playing   File: WordServiceSupport.java   Source Code and License Vote up 5 votes
@Override
public Observable<String> enumerate(Observable<String> words) {
    return words.zipWith(
            Observable.range(1, Integer.MAX_VALUE),
            (string, index) -> String.format("%2d. %s", index, string)
    );
}
 
Example 2
Project: reactive-playing   File: WordServiceSupport.java   Source Code and License Vote up 5 votes
@Override
public Observable<String> enumerate(Observable<String> words) {
    return words.zipWith(
            Observable.range(1, Integer.MAX_VALUE),
            (string, index) -> String.format("%2d. %s", index, string)
    );
}
 
Example 3
Project: rxjavatraining   File: StockFinderTest.java   Source Code and License Vote up 5 votes
@Test
public void testStockPriceFinderFindTheLatestCloseBug() throws IOException {
    Observable<String> stockNames = Observable.just("M", "MSFT", "BTC", "T", "ORCL");
    Observable<String> urls = stockNames.map(s -> "https://finance.google.com/finance/historical?output=csv&q=" + s);
    Observable<String> contentObservable = urls.flatMap(u -> Observable.fromFuture(createFuture(u)).onErrorResumeNext((Throwable e) -> Observable.empty()));
    Observable<String> lineObservable = contentObservable.doOnNext(s -> System.out.println(">>>>" + s)).flatMap(doc ->
            Observable.fromArray(doc.split("\n")).skip(1).take(1));
    Observable<Tuple2<String, Double>> tupleObservable = stockNames.zipWith(lineObservable.map(s -> s.split(",")[4]).map(Double::parseDouble), Tuple2::new);
    tupleObservable.subscribe(System.out::println);
}