當前位置: 首頁>>代碼示例>>Java>>正文


Java Observable.zip方法代碼示例

本文整理匯總了Java中io.reactivex.Observable.zip方法的典型用法代碼示例。如果您正苦於以下問題:Java Observable.zip方法的具體用法?Java Observable.zip怎麽用?Java Observable.zip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.reactivex.Observable的用法示例。


在下文中一共展示了Observable.zip方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import io.reactivex.Observable; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    recyclerView = (RecyclerView) findViewById(R.id.recyclerview);

    recyclerView.setLayoutManager(new LinearLayoutManager(getBaseContext()));
    adapter = new Adapter();
    recyclerView.setAdapter(adapter);

    loadWithRetroJsoup();

    Observable.zip(
            Observable.just(""),
            Observable.just("&"),
            new BiFunction<String, String, String>(){

                @Override
                public String apply(@NonNull String s, @NonNull String s2) throws Exception {
                    return null;
                }
            }
    );
}
 
開發者ID:florent37,項目名稱:RxRetroJsoup,代碼行數:25,代碼來源:MainActivity.java

示例2: processStock

import io.reactivex.Observable; //導入方法依賴的package包/類
public Observable<Tuple2<String, Double>> processStock(List<String> stocks, Function<String, String> f) {
    Observable<String> stockNames = Observable.fromIterable(stocks);
    Observable<String> urls = stockNames.map(s -> "https://finance.google.com/finance/historical?output=csv&q=" + s);
    Observable<Optional<String>> optionalObservable = urls
            .subscribeOn(Schedulers.from(executorService))
            .flatMap(s -> {
                try {
                    return Observable.just(Optional.of(f.apply(s)));
                } catch (Throwable t) {
                    return Observable.just(Optional.<String>empty());
                }
            })

            .observeOn(Schedulers.computation())
            .map(opt -> opt.map(doc -> doc.split("\n")[1].split(",")[4]))
            .doOnNext(x -> System.out.println(">>>>" + x));
    return Observable.zip(stockNames, optionalObservable, (name, price) ->
            new Tuple2<>(name, Double.parseDouble(price.orElse("0.0"))));
}
 
開發者ID:dhinojosa,項目名稱:rxjavatraining,代碼行數:20,代碼來源:ObservableTestingTest.java

示例3: createFinalFlowObservable

import io.reactivex.Observable; //導入方法依賴的package包/類
@Override
public Observable<JSONObject> createFinalFlowObservable() {
    return Observable.zip(getMe, chapter, new BiFunction<JSONObject, JSONArray, JSONObject>() {
        @Override
        public JSONObject apply(@NonNull JSONObject jsonObject, @NonNull JSONArray jsonArray) throws Exception {
            String name = jsonObject.getString("name");
            Log.d("NONO", "TestGroupTask---" + name + ":" + jsonArray.length());
            return new JSONObject();
        }
    });


}
 
開發者ID:killnono,項目名稱:Dalaran,代碼行數:14,代碼來源:TestGroupTask.java

示例4: getAllProducts

import io.reactivex.Observable; //導入方法依賴的package包/類
/**
 * Get a list with all products from backend
 */
public Observable<List<Product>> getAllProducts() {
  return Observable.zip(getProducts(0), getProducts(1), getProducts(2), getProducts(3),
      (products0, products1, products2, products3) -> {
        List<Product> productList = new ArrayList<Product>();
        productList.addAll(products0);
        productList.addAll(products1);
        productList.addAll(products2);
        productList.addAll(products3);
        return productList;
      });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:ProductBackendApiDecorator.java

示例5: get

import io.reactivex.Observable; //導入方法依賴的package包/類
public <CLASS> Observable<CLASS> get(Class<CLASS> theClass) {
    return Observable.zip(
            onEvent(theClass),
            postAsObservable(new AskedEvent(theClass)),
            new BiFunction<CLASS, Object, CLASS>() {
                @Override
                public CLASS apply(@NonNull CLASS neededObject, @NonNull Object _useless) throws Exception {
                    return neededObject;
                }
            });
}
 
開發者ID:datalink747,項目名稱:Rx_java2_soussidev,代碼行數:12,代碼來源:RxBus_java.java


注:本文中的io.reactivex.Observable.zip方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。