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


Java Maybe.empty方法代码示例

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


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

示例1: main

import io.reactivex.Maybe; //导入方法依赖的package包/类
public static void main(String[] args) {
// has emission
        Maybe<Integer> presentSource = Maybe.just(100);
        presentSource.subscribe(s -> System.out.println("Process 1 received:" + s),
                Throwable::printStackTrace,
                () -> System.out.println("Process 1 done!"));
//no emission
        Maybe<Integer> emptySource = Maybe.empty();
        emptySource.subscribe(s -> System.out.println("Process 2 received:" + s),
                Throwable::printStackTrace,
                () -> System.out.println("Process 2 done!"));
    }
 
开发者ID:PacktPublishing,项目名称:Learning-RxJava,代码行数:13,代码来源:Ch2_30.java

示例2: getProfile

import io.reactivex.Maybe; //导入方法依赖的package包/类
@Override
public Maybe<Profile> getProfile(String uid) {
    if (returnFailure){
        return Maybe.error(new Exception());
    } else if (returnEmpty) {
        return Maybe.empty();
    }
    //TODO: make static fake Profile for testing
    return Maybe.just(fakeProfile);
}
 
开发者ID:BracketCove,项目名称:Profiler,代码行数:11,代码来源:FakeDatabaseService.java

示例3: getThumbnails

import io.reactivex.Maybe; //导入方法依赖的package包/类
@Override
public Maybe<List<Photo>> getThumbnails(ContentResolver resolver) {
    if (returnFailure){
        return Maybe.empty();
    } else {
        List<Photo> list = new ArrayList<>();
        for (int i = 0; i < 9; i++){
            list.add(new Photo("photo-" + Integer.toString(i)));
        }
        return Maybe.just(list);
    }
}
 
开发者ID:BracketCove,项目名称:Profiler,代码行数:13,代码来源:FakePhotoService.java

示例4: demo5

import io.reactivex.Maybe; //导入方法依赖的package包/类
private void demo5() {
    Completable completable = Completable.fromAction(() -> {
        log("Let's do something");
    });

    completable.subscribe(() -> {
        log("Finished");
    }, throwable -> {
        log(throwable);
    });


    Single.just("One item")
            .subscribe((item) -> {
                log(item);
            }, (throwable) -> {
                log(throwable);
            });

    Maybe.empty();
    Maybe.just("Item")
            .subscribe(s -> {
                log("On Success: " + s);
            });

    Maybe.just("Item")
            .subscribe(s -> {
                log("On Success: " + s);
            }, throwable -> log("error"));

    Maybe.just("Item")
            .subscribe(
                    s -> log("success: " + s),
                    throwable -> log("error"),
                    () -> log("onComplete")
            );
}
 
开发者ID:PacktPublishing,项目名称:Reactive-Android-Programming,代码行数:38,代码来源:MainActivity.java

示例5: maybeFromNonNullItem

import io.reactivex.Maybe; //导入方法依赖的package包/类
private <R> Maybe<R> maybeFromNonNullItem(Function<T, R> flatMapper) {
    R newItem = Invoker.invoke(flatMapper, chain.item);
    if (newItem != null) {
        return Maybe.just(newItem);
    } else {
        return Maybe.empty();
    }
}
 
开发者ID:Ahmed-Adel-Ismail,项目名称:J-Chain,代码行数:9,代码来源:Optional.java

示例6: getSavedState

import io.reactivex.Maybe; //导入方法依赖的package包/类
/**
 * Gets the current state as a Maybe. The Maybe will emit a single bundle if there is a previous state
 * or if the state is missing it will emit no events and call the onComplete event
 */
@NonNull
public static Maybe<Bundle> getSavedState(@NonNull Activity activity) {
  PreConditions.throwIfNotOnMainThread();
  Bundle prevState = getSavedStateDirect(activity);
  if(prevState != null) {
    return Maybe.just(prevState);
  } else {
    return Maybe.empty();
  }
}
 
开发者ID:jimandreas,项目名称:android-rxmvp-sandbox,代码行数:15,代码来源:RxSaveState.java

示例7: generateEmailCredentials

import io.reactivex.Maybe; //导入方法依赖的package包/类
private Maybe<PasswordCredentials> generateEmailCredentials(User user) {
    if (user.getCredentials() != null) {
        return passwordCredentialsFacade.generateEmailCredentials(user).toMaybe();
    }

    return Maybe.empty();
}
 
开发者ID:Atypon-OpenSource,项目名称:wayf-cloud,代码行数:8,代码来源:UserFacadeImpl.java

示例8: getPokemonMaybeFromCache

import io.reactivex.Maybe; //导入方法依赖的package包/类
private Maybe<Pokemon> getPokemonMaybeFromCache() {
    if (pokemonCache != null) {
        return Maybe.just(pokemonCache);
    } else {
        return Maybe.empty();
    }
}
 
开发者ID:ragdroid,项目名称:Dahaka,代码行数:8,代码来源:UserManager.java

示例9: apply

import io.reactivex.Maybe; //导入方法依赖的package包/类
@Override
public Maybe<Address> apply(@io.reactivex.annotations.NonNull List<Address> addresses) throws Exception {
    return addresses.isEmpty() ? Maybe.<Address>empty() : Maybe.just(addresses.get(0));
}
 
开发者ID:TechIsFun,项目名称:RxJava2-weather-example,代码行数:5,代码来源:Geocoding.java

示例10: Open

import io.reactivex.Maybe; //导入方法依赖的package包/类
public Open() {
    this.response = Maybe.empty();
}
 
开发者ID:navinilavarasan,项目名称:rxWebSocket,代码行数:4,代码来源:RxWebsocket.java

示例11: flatMapMaybe

import io.reactivex.Maybe; //导入方法依赖的package包/类
/**
 * apply an action to the stored item if not null, this action will cause this {@link Optional}
 * to be changed to a {@link Maybe}, if the stored item is {@code null} then an empty
 * {@link Maybe} will be returned
 *
 * @param flatMapper the flat-mapped {@link Function}
 * @param <R>        the new expected type
 * @return a {@link Maybe} that either hold a value, or is empty
 */
public <R> Maybe<R> flatMapMaybe(Function<T, R> flatMapper) {
    if (chain.item != null) {
        return maybeFromNonNullItem(flatMapper);
    } else {
        return Maybe.empty();
    }
}
 
开发者ID:Ahmed-Adel-Ismail,项目名称:J-Chain,代码行数:17,代码来源:Optional.java


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