当前位置: 首页>>代码示例>>Java>>正文


Java Observable.combineLatest方法代码示例

本文整理汇总了Java中io.reactivex.Observable.combineLatest方法的典型用法代码示例。如果您正苦于以下问题:Java Observable.combineLatest方法的具体用法?Java Observable.combineLatest怎么用?Java Observable.combineLatest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.reactivex.Observable的用法示例。


在下文中一共展示了Observable.combineLatest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: zipMaps

import io.reactivex.Observable; //导入方法依赖的package包/类
public static <T, S> Observable<Map<T, S>> zipMaps(final Map<T, Observable<S>> tasks) {

        Objects.requireNonNull(tasks, "tasks is null");

        return Observable.combineLatest(
            tasks.entrySet()
                .stream()
                .map(entry -> Observable.combineLatest(
                    Observable.just(entry.getKey()),
                    entry.getValue(),
                    Pair::with))
                .collect(ImmutableList.toImmutableList()),
            xs -> Arrays.stream(xs)
                .map(x -> (Pair<T, S>)x)
                .collect(ImmutableMap.toImmutableMap(Pair::getValue0, Pair::getValue1)));
    }
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:17,代码来源:MoreObservables.java

示例2: getProductWithShoppingCartInfo

import io.reactivex.Observable; //导入方法依赖的package包/类
private Observable<ProductDetail> getProductWithShoppingCartInfo(int productId) {
  List<Observable<?>> observables =
      Arrays.asList(backendApi.getProduct(productId), shoppingCart.itemsInShoppingCart());

  return Observable.combineLatest(observables, objects -> {
    Product product = (Product) objects[0];
    List<Product> productsInShoppingCart = (List<Product>) objects[1];
    boolean inShoppingCart = false;
    for (Product p : productsInShoppingCart) {
      if (p.getId() == productId) {
        inShoppingCart = true;
        break;
      }
    }

    return new ProductDetail(product, inShoppingCart);
  });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:DetailsInteractor.java

示例3: captchaCommand

import io.reactivex.Observable; //导入方法依赖的package包/类
public RxCommand<String> captchaCommand() {
    if (_captchaCommand == null) {
        Observable<Boolean> enabled = Observable.combineLatest(
                _phoneNumberValid,
                countdownCommand().executing(),
                (valid, executing) -> valid && !executing);

        _captchaCommand = RxCommand.create(enabled, o -> {
            String phone = phoneNumber.value().toString();
            Timber.i("fetch captcha with %s", phone);
            Observable<String> fetchCode =  fetchCaptcha(phone);
            Observable<String> countdown =  Observable.defer(() -> countdownCommand().execute(null).ignoreElements().toObservable()) ;
            return Observable.concat(fetchCode, countdown);
        });
    }
    return _captchaCommand;
}
 
开发者ID:listenzz,项目名称:RxCommand,代码行数:18,代码来源:LoginViewModel.java

示例4: loginCommand

import io.reactivex.Observable; //导入方法依赖的package包/类
public RxCommand<Boolean> loginCommand() {
    if (_loginCommand == null) {
        Observable<Boolean> loginInputValid = Observable.combineLatest(
                _captchaValid,
                _phoneNumberValid,
                (captchaValid, phoneValid) -> captchaValid && phoneValid);

        _loginCommand = RxCommand.create(loginInputValid, o -> {
            String phone = this.phoneNumber.value().toString();
            String captcha = this.captcha.value().toString();
            return login(phone, captcha);
        });
    }
    return _loginCommand;
}
 
开发者ID:listenzz,项目名称:RxCommand,代码行数:16,代码来源:LoginViewModel.java


注:本文中的io.reactivex.Observable.combineLatest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。