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


Java Maybe.just方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: getUser

import io.reactivex.Maybe; //导入方法依赖的package包/类
@Override
public Maybe<User> getUser() {
    if (returnFailure){
        return Maybe.error(new Exception());
    }

    //TODO: make static user for this test
    return Maybe.just(fakeUser);
}
 
开发者ID:BracketCove,项目名称:Profiler,代码行数:10,代码来源:FakeAuthService.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: 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

示例8: 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

示例9: Open

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


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