本文整理匯總了Java中io.reactivex.Observable.zipWith方法的典型用法代碼示例。如果您正苦於以下問題:Java Observable.zipWith方法的具體用法?Java Observable.zipWith怎麽用?Java Observable.zipWith使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.reactivex.Observable
的用法示例。
在下文中一共展示了Observable.zipWith方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: enumerate
import io.reactivex.Observable; //導入方法依賴的package包/類
@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)
);
}
示例2: testStockPriceFinderFindTheLatestCloseBug
import io.reactivex.Observable; //導入方法依賴的package包/類
@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);
}