當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。