SlideShare a Scribd company logo


















public interface Callback {
void onSuccess(List<Recipe> recipes);
void onError(Throwable t);
}
public void searchRecipe(String keyword, Callback callback) {

recipeApiClient.search(keyword, callback);

}
searchRecipe(“ステーキ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

addToList(recipes);
}
@Override
public void onError(Throwable t) {
showErrorView(t);
}
});

}
searchRecipe(“ステーキ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

addToList(recipes);
}
@Override
public void onError(Throwable t) {
showErrorView(t);
}
});

}
searchRecipe(“ステーキ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

addToList(recipes);
}
@Override
public void onError(Throwable t) {
showErrorView(t);
}
});

}
searchRecipe(“ステーキ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

addToList(recipes);
}
@Override
public void onError(Throwable t) {
showErrorView(t);
}
});

}
searchRecipe(“ステーキ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

addToList(recipes);
}
@Override
public void onError(Throwable t) {
showErrorView(t);
}
});

}
!
searchRecipe(“ステーキ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

addToList(recipes);
}
@Override
public void onError(Throwable t) {
showErrorView(t);
}
});

}
!
!
searchRecipe(“ステーキ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

addToList(recipes);
}
@Override
public void onError(Throwable t) {
showErrorView(t);
}
});

}
!
!
!
searchRecipe(“ステーキ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

addToList(recipes);
}
@Override
public void onError(Throwable t) {
showErrorView(t);
}
});

}
!
!
!
!
searchRecipe(“ステーキ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

addToList(recipes);
}
@Override
public void onError(Throwable t) {
showErrorView(t);
}
});

}
searchRecipe(“ステーキ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

addToList(recipes);
}
@Override
public void onError(Throwable t) {
showErrorView(t);
}
});

}
searchRecipe(“ステーキ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

addToList(recipes);
}
@Override
public void onError(Throwable t) {
showErrorView(t);
}
});

}
searchRecipe(“ステーキ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

addToList(recipes);
}
@Override
public void onError(Throwable t) {
showErrorView(t);
}
});

}
searchRecipe(“ステーキ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

addToList(recipes);
}
@Override
public void onError(Throwable t) {
showErrorView(t);
}
});

}
"


# app/build.gradle

dependencies {

compile 'io.reactivex:rxjava:1.1.1'
compile 'io.reactivex:rxandroid:1.1.0'

}
public void searchRecipe(String keyword, Callback callback) {

recipeApiClient.search(keyword, callback);

}
public void searchRecipe(String keyword, Callback callback) {

recipeApiClient.search(keyword, callback);

}
public void searchRecipe(String keyword, Callback callback) {

recipeApiClient.search(keyword, callback);

}


public void searchRecipe(String keyword) {

recipeApiClient.search(keyword, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {
}
@Override
public void onError(Throwable t) {
}
});

}


public void searchRecipe(String keyword) {

recipeApiClient.search(keyword, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {
}
@Override
public void onError(Throwable t) {
}
});

}


public Observable<List<Recipe>> searchRecipe(String keyword) {

recipeApiClient.search(keyword, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

}
@Override
public void onError(Throwable t) {

}
});

}


public Observable<List<Recipe>> searchRecipe(String keyword) {

recipeApiClient.search(keyword, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

}
@Override
public void onError(Throwable t) {

}
});

}
public Observable<List<Recipe>> searchRecipe(String keyword) {
return Observable.create(subscriber -> {























});
}
void


recipeApiClient.search(keyword, new Callback() {

@Override

public void onSuccess(List<Recipe> recipes) {





}
@Override
public void onError(Throwable t) {

}

});
public Observable<List<Recipe>> searchRecipe(String keyword) {
return Observable.create(subscriber -> {

recipeApiClient.search(keyword, new Callback() {

@Override

public void onSuccess(List<Recipe> recipes) {





}
@Override
public void onError(Throwable t) {


}
});
});
}
void
public Observable<List<Recipe>> searchRecipe(String keyword) {
return Observable.create(subscriber -> {

recipeApiClient.search(keyword, new Callback() {

@Override

public void onSuccess(List<Recipe> recipes) {

subscriber.onNext(recipes);// イベントの通知
subscriber.onCompleted(); // 全イベントが終了した通知

}
@Override
public void onError(Throwable t) {
subscriber.onError(t); // 処理内で失敗した通知
}
});
});
}
void
public Observable<List<Recipe>> searchRecipe(String keyword) {
return Observable.create(subscriber -> {

recipeApiClient.search(keyword, new Callback() {

@Override

public void onSuccess(List<Recipe> recipes) {

subscriber.onNext(recipes);// イベントの通知
subscriber.onCompleted(); // 全イベントが終了した通知

}
@Override
public void onError(Throwable t) {
subscriber.onError(t); // 処理内で失敗した通知
}
});
});
}
void
public Observable<List<Recipe>> searchRecipe(String keyword) {
return Observable.create(subscriber -> {

recipeApiClient.search(keyword, new Callback() {

@Override

public void onSuccess(List<Recipe> recipes) {

subscriber.onNext(recipes);// イベントの通知
subscriber.onCompleted(); // 全イベントが終了した通知

}
@Override
public void onError(Throwable t) {
subscriber.onError(t); // 処理内で失敗した通知
}
});
});
}
void
public List<Recipe> searchRecipe(String keyword) throws HttpException {
// okhttpとかHttpClientで同期通信

}


public Observable<List<Recipe>> searchRecipe(String keyword) {
return Observable.create(subscriber -> {
try{

List<Recipe> recipes = ApiClient.search(keyword);
subscriber.onNext(recipes);
subscriber.onFinished();
} catch(HttpException e) {

subscriber.onError(e);

}
}
searchRecipe(“ステーキ”)
.subscribe(new Subscriber<List<Recipe>>() {

@Override

public void onNext(List<Recipe> recipe) {

addToList(recipes);

}

@Override

public void onError(Throwable e) {

showErrorMessage(t);

}



@Override

public void onCompleted() { 

});
);
searchRecipe(“ステーキ”)
.subscribe(new Subscriber<List<Recipe>>() {

@Override

public void onNext(List<Recipe> recipe) {

addToList(recipes);

}

@Override

public void onError(Throwable e) {

showErrorMessage(t);

}



@Override

public void onCompleted() { 

});
);
searchRecipe(“ステーキ”)
.subscribe(new Subscriber<List<Recipe>>() {

@Override

public void onNext(List<Recipe> recipe) {

addToList(recipes);

}

@Override

public void onError(Throwable e) {

showErrorMessage(t);

}



@Override

public void onCompleted() { 

});
);
searchRecipe(“ステーキ”)
.subscribe(new Subscriber<List<Recipe>>() {

@Override

public void onNext(List<Recipe> recipe) {

addToList(recipes);

}

@Override

public void onError(Throwable e) {

showErrorMessage(t);

}



@Override

public void onCompleted() { 

});
);
searchRecipe(“ステーキ”)
.subscribe(new Subscriber<List<Recipe>>() {

@Override

public void onNext(List<Recipe> recipe) {

addToList(recipes);

}

@Override

public void onError(Throwable e) {

showErrorMessage(t);

}



@Override

public void onCompleted() { 

});
);
!
searchRecipe(“ステーキ”)
.subscribe(new Subscriber<List<Recipe>>() {

@Override

public void onNext(List<Recipe> recipe) {

addToList(recipes);

}

@Override

public void onError(Throwable e) {

showErrorMessage(t);

}



@Override

public void onCompleted() { 

});
);
!
!
searchRecipe(“ステーキ”)
.subscribe(new Subscriber<List<Recipe>>() {

@Override

public void onNext(List<Recipe> recipe) {

addToList(recipes);

}

@Override

public void onError(Throwable e) {

showErrorMessage(t);

}



@Override

public void onCompleted() { 

});
);
!
!
!
searchRecipe(“ステーキ”)
.subscribe(new Subscriber<List<Recipe>>() {

@Override

public void onNext(List<Recipe> recipe) {

addToList(recipes);

}

@Override

public void onError(Throwable e) {

showErrorMessage(t);

}



@Override

public void onCompleted() { 

});
);
!
!
!
!
searchRecipe(“ステーキ”)
.subscribe(recipes -> {
addToList(recipes);
},
throwable -> {
showErrorMessage(t);
},
() -> {

// 省略可能

}
);
searchRecipe(“ステーキ”)
.subscribe(recipes -> {
addToList(recipes);
},
throwable -> {
showErrorMessage(t);
},
() -> {

// 省略可能

}
);
searchRecipe(“ステーキ”)
.subscribe(recipes -> {
addToList(recipes);
},
throwable -> {
showErrorMessage(t);
},
() -> {

// 省略可能

}
);
searchRecipe(“ステーキ”)
.subscribe(recipes -> {
addToList(recipes);
},
throwable -> {
showErrorMessage(t);
},
() -> {

// 省略可能

}
);
!
!
!
!
🙇
searchRecipeBy(“ステーキ”)

.map(recipes -> { /* todo something */ })

.subscribeOn(Schedulers.io())

.map(recipes -> { /* todo something */ })
.subscribe(recipes -> {});
searchRecipeBy(“ステーキ”)

.map(recipes -> { /* todo something */ })

.subscribeOn(Schedulers.io())

.map(recipes -> { /* todo something */ })
.subscribe(recipes -> {});


searchRecipeBy(“ステーキ”)

.map(recipes -> { /* todo something */ })

.subscribeOn(Schedulers.io())

.observeOn(AndroidSchedulers.mainThread())

.map(recipes -> { /* todo something */ })
.observeOn(Schedulers.io())
.subscribe(recipes -> {});
searchRecipeBy(“ステーキ”)

.map(recipes -> { /* todo something */ })

.subscribeOn(Schedulers.io())

.observeOn(AndroidSchedulers.mainThread())

.map(recipes -> { /* todo something */ })
.observeOn(Schedulers.io())
.subscribe(recipes -> {});
searchRecipeBy(“ステーキ”)

.map(recipes -> { /* todo something */ })

.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(recipes -> {});


searchRecipe(“ステーキ”)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(recipes -> {
addToList(recipes);
},
throwable -> {
showErrorMessage(t);
}
);
searchRecipe(“ステーキ”)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(recipes -> {
addToList(recipes);
},
throwable -> {
showErrorMessage(t);
}
);
searchRecipe(“ステーキ”)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(recipes -> {
addToList(recipes);
},
throwable -> {
showErrorMessage(t);
}
);
searchRecipe(“ステーキ”)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(recipes -> {
addToList(recipes);
},
throwable -> {
showErrorMessage(t);
}
);
!
!
!
!


searchRecipeBy(“ハンバーグ”, new Callback() {
@Override
public void onSuccess(List<Recipe> recipes) {

if(getActivity() == null) { return; }

addToList(recipes);
}
@Override
public void onError(Throwable t) {

if(getActivity() == null) { return; }
showErrorMessage(t);
}
});

}


# app/build.gradle

dependencies {

compile 'com.trello:rxlifecycle:0.4.0'
compile 'com.trello:rxlifecycle-components:0.4.0'

}
searchRecipeBy(“ハンバーグ”)
.compose(bindToLifecycle())

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(recipes -> {
addList(recipes);
},
throwable -> {
showErrorMessage(t);
}
);
searchRecipeBy(“ハンバーグ”)
.compose(bindToLifecycle())

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(recipes -> {
addList(recipes);
},
throwable -> {
showErrorMessage(t);
}
);
searchRecipeBy(“ハンバーグ”)
.compose(bindToLifecycle())

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(recipes -> {
addList(recipes);
},
throwable -> {
showErrorMessage(t);
}
);
searchRecipeBy(“ハンバーグ”)
.compose(bindToLifecycle())

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(recipes -> {
addList(recipes);
},
throwable -> {
showErrorMessage(t);
}
);
!
!
!
!
searchRecipeBy(“ハンバーグ”)
.compose(bindToLifecycle())

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(recipes -> {
addList(recipes);
},
throwable -> {
showErrorMessage(t);
}
);
searchRecipeBy(“ハンバーグ”)
.compose(bindToLifecycle())

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(recipes -> {
addList(recipes);
},
throwable -> {
showErrorMessage(t);
}
);
searchRecipeBy(“ハンバーグ”)
.compose(bindToLifecycle())

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(recipes -> {
addList(recipes);
},
throwable -> {
showErrorMessage(t);
}
);


searchRecipeBy(“ハンバーグ”)
.compose(bindToLifecycle())

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(recipes -> {
addList(recipes);
},
throwable -> {
showErrorMessage(t);
}
);






#
#
#
#
!
!
!
#
#
#
#
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
Observable.combineLatest(

Observable.just(1),

Observable.just(2),

(i1,i2) -> i1 + i2 // この場合、3が次のオペレーターに渡る

);
Observable.combineLatest(

Observable.just(1),

Observable.just(2),

(i1,i2) -> Pair.create(i1, i2)

);
Observable.combineLatest(

Observable.just(1),

Observable.just(2),

Pair::create

);
Observable.combineLatest(
searchRecipe(“ステーキ”),
searchAd(“ステーキ”), // 広告情報を取得するメソッドだと思って下さい
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(pair -> {
addToListWithBannerIfExist(pair.first, pair.second);
},
throwable -> {
showErrorMessage(t);
}
);
Observable.combineLatest(
searchRecipe(“ステーキ”),
searchAd(“ステーキ”), // 広告情報を取得するメソッドだと思って下さい
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(pair -> {
addToListWithBannerIfExist(pair.first, pair.second);
},
throwable -> {
showErrorMessage(t);
}
);
Observable.combineLatest(
searchRecipe(“ステーキ”),
searchAd(“ステーキ”), // 広告情報を取得するメソッドだと思って下さい
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(pair -> {
addToListWithBannerIfExist(pair.first, pair.second);
},
throwable -> {
showErrorMessage(t);
}
);
Observable.combineLatest(
searchRecipe(“ステーキ”),
searchAd(“ステーキ”), // 広告情報を取得するメソッドだと思って下さい
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(pair -> {
addToListWithBannerIfExist(pair.first, pair.second);
},
throwable -> {
showErrorMessage(t);
}
);
Observable.combineLatest(
searchRecipe(“ステーキ”),
searchAd(“ステーキ”), // 広告情報を取得するメソッドだと思って下さい
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(pair -> {
addToListWithBannerIfExist(pair.first, pair.second);
},
throwable -> {
showErrorMessage(t);
}
);
Observable.combineLatest(
searchRecipe(“ステーキ”),
searchAd(“ステーキ”), // 広告情報を取得するメソッドだと思って下さい
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(pair -> {
addToListWithBannerIfExist(pair.first, pair.second);
},
throwable -> {
showErrorMessage(t);
}
);
Observable.combineLatest(
searchRecipe(“ステーキ”),
searchAd(“ステーキ”), // 広告情報を取得するメソッドだと思って下さい
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(pair -> {
addToListWithBannerIfExist(pair.first, pair.second);
},
throwable -> {
showErrorMessage(t);
}
);
Observable.combineLatest(
searchRecipe(“ステーキ”),
searchAd(“ステーキ”), // 広告情報を取得するメソッドだと思って下さい
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(pair -> {
addToListWithBannerIfExist(pair.first, pair.second);
},
throwable -> {
showErrorMessage(t);
}
);
😱
😱
😱
AdObservable(“タマゴ”)
.onErrorReturn(throwable -> AdModel.EmptyData());
public Observable<AdModel> searchAd(String keyword) {
return Observable.create(subscriber -> {
try{

AdModel adModel = adClient.search(keyword);
subscriber.onNext(adModel);
} catch(HttpException e) {

subscriber.onError(e);

})
.onErrorReturn(e -> {
return AdModel.createEmptyData();

});
}
public Observable<AdModel> searchAd(String keyword) {
return Observable.create(subscriber -> {
try{

AdModel adModel = adClient.search(keyword);
subscriber.onNext(adModel);
} catch(HttpException e) {

subscriber.onError(e);

})
.onErrorReturn(e -> {
return AdModel.createEmptyData();

});
}
public Observable<AdModel> searchAd(String keyword) {
return Observable.create(subscriber -> {
try{

AdModel adModel = adClient.search(keyword);
subscriber.onNext(adModel);
} catch(HttpException e) {

subscriber.onError(e);

})
.onErrorReturn(e -> {
return AdModel.createEmptyData();

});
}
public Observable<AdModel> searchAd(String keyword) {
return Observable.create(subscriber -> {
try{

AdModel adModel = adClient.search(keyword);
subscriber.onNext(adModel);
} catch(HttpException e) {

subscriber.onError(e);

})
.onErrorReturn(e -> {
return AdModel.createEmptyData();

});
}
public Observable<AdModel> searchAd(String keyword) {
return Observable.create(subscriber -> {
try{

AdModel adModel = adClient.search(keyword);
subscriber.onNext(adModel);
} catch(HttpException e) {

subscriber.onError(e);

})
.onErrorReturn(e -> {
return AdModel.createEmptyData();

});
}
Observable.combineLatest(
searchRecipe(“ステーキ”),
searchAd(“ステーキ”),
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe( /* 省略 */ );
Observable.combineLatest(
searchRecipe(“ステーキ”),
searchAd(“ステーキ”),
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe( /* 省略 */ );
Observable.combineLatest(
searchRecipe(“ステーキ”),
searchAd(“ステーキ”),
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe( /* 省略 */ );
Observable.combineLatest(
searchRecipe(“ステーキ”),
searchAd(“ステーキ”),
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe( /* 省略 */ );
Observable.combineLatest(
searchRecipe(“ステーキ”),
searchAd(“ステーキ”),
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe( /* 省略 */ );
Observable.combineLatest(
searchRecipe(“ステーキ”).subscribeOn(schedulers.io()),
searchAd(“ステーキ”).subscribeOn(schedulers.io()),
Pair::create
)

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe( /* 省略 */ );


AdObservable(“タマゴ”)
.retry(1); // 例外が発生した場合1回だけリトライする
AdObservable(“タマゴ”)
.retry((count, throwable) -> count > 2)


public Observable<AdModel> searchAd(String keyword) {
return Observable.create(subscriber -> {
try{

AdModel ad = AdClient.search(keyword);
subscriber.onNext(ad);
} catch(HttpException e) {

subscriber.onError(e);

})
.retry(1)
.onErrorReturn(e -> {
return AdModel.createEmptyData();

});
}
!
!
!


!
!
!
♥
♥
♥


!
!
!
♥
♥
♥
!
!
!
♥
♥
♥
searchRecipe(“ステーキ”)
.flatMap(recipes -> fetchLikedRecipeIds(recipes))
.subscribe(recipeIds -> {})
searchRecipe(“ステーキ”)
.flatMap(recipes -> fetchLikedRecipeIds(recipes))
.subscribe(recipeIds -> {})
searchRecipe(“ステーキ”)
.flatMap(recipes -> fetchLikedRecipeIds(recipes))
.subscribe(recipeIds -> {})
searchRecipe(“ステーキ”)
.flatMap(recipes -> fetchLikedRecipeIds(recipes))
.subscribe(recipeIds -> {})
searchRecipe(“ステーキ”)

.flatMap(recipes -> 

Observable.combineLatest(
Observable.just(recipes), // レシピリストをそのまま渡す

fetchLikedRecipe(recipes)), //レシピリストからLikeしたレシピIdを取得
Pair::create

)

)

.map(this::mergeLikeState) // mapでLike状態をレシピインスタンスに反映させる(省略)
.subscribe(recipes -> {})
searchRecipe(“ステーキ”)

.flatMap(recipes -> 

Observable.combineLatest(
Observable.just(recipes), // レシピリストをそのまま渡す

fetchLikedRecipe(recipes)), //レシピリストからLikeしたレシピIdを取得
Pair::create

)

)

.map(this::mergeLikeState) // mapでLike状態をレシピインスタンスに反映させる(省略)
.subscribe(recipes -> {})
searchRecipe(“ステーキ”)

.flatMap(recipes -> 

Observable.combineLatest(
Observable.just(recipes), // レシピリストをそのまま渡す

fetchLikedRecipe(recipes)), //レシピリストからLikeしたレシピIdを取得
Pair::create

)

)

.map(this::mergeLikeState) // mapでLike状態をレシピインスタンスに反映させる(省略)
.subscribe(recipes -> {})
searchRecipe(“ステーキ”)

.flatMap(recipes -> {

fetchLikedRecipe(recipes)

.map(likeIds -> {

mergeLikeState(recipes, likeIds);

});

}

)
.subscribe(recipes -> {})
public Observable<List<Recipe>> searchRecipeWithLikeState(String keyword) {
searchRecipe(keyword)
.flatMap(recipes ->
Observable.combineLatest(
Observable.just(recipes),
fetchLikedRecipeIds(recipes)),
Pair::create
)
)
.map(this::mergeLikeState)
}

public Func1<List<Recipe>> mergeLikeState(Pair<List<Recipe>, Integer> pair) {

// Like状態をレシピインスタンスに反映させる(省略)

}
!
!
!
♥
♥
♥
!
!
!
♥
♥
♥
!
!
!
♥
♥
♥
!
!
!
♥
♥
♥
!
!
!
♥
♥
♥
!
!
!
♥
♥
♥
!
!
!
♥
♥
♥
!
!
!
♥
♥
♥
!
!
!
♥
♥
♥
!
!
!
♥
♥
♥
!
!
!
♥
♥
♥
!
!
!
♥
♥
♥
!
!
!
♥
♥
♥
Observable.combineLatest(
searchRecipeWithLikeState(“ステーキ”)
.subscribeOn(schedulers.io()),
searchAd(“ステーキ”)
.subscribeOn(schedulers.io()),
Pair::create
)
.compose(bindToLifecycle())

.subscribeOn(schedulers.io())

.observeOn(AndroidSchedulers.mainThread())
.subscribe(pair -> {
addToList(pair.first, pair.second);
},
throwable -> {
showErrorMessage(t);
}
);
!
!
!
♥
♥
♥
Observable.combineLatest(

Observable.just(1),

Observable.just(2),

(i1,i2) -> i1 + i2

);


searchRecipe(“ステーキ”)
.flatMap(recipes -> recipeClient.fetchLikedRecipeIds(recipes))
.subscribe(recipeIds -> {})


public class Tuple3<T1, T2, T3> {

public T1 first; public T2 second; public T3 third;

public Tuple3(T1 first, T2 second, T3 third) {

this.first = first;

this.second = second;

this.third = third;

}

public static <T1, T2, T3> Tuple3<T1, T2, T3> create(T1 t1, T2 t2, T3 t3) {

return new Tuple3<>(t1, t2, t3);

}

}
// in your CustomApplication
public void onCreate(Bundle saveInstanceState){

super.onCreate();
System.setProperty("rx.ring-buffer.size", "32");
}
Single.create(subscriber -> {

subscriber.onSuccess("Hello world");

}).subscribe(text -> {

System.out.println(text);

}, throwable -> {

Crashlytics.logException(e);

});


Completable.create(subscriber -> { 

subscriber.onCompleted()

}).subscribe(throwable -> {

Crashlytics.logException(e);

}, () -> {



});



More Related Content

What's hot

F#によるFunctional Programming入門
F#によるFunctional Programming入門F#によるFunctional Programming入門
F#によるFunctional Programming入門
bleis tift
 
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
Takuto Wada
 
関数型プログラミング入門 with OCaml
関数型プログラミング入門 with OCaml関数型プログラミング入門 with OCaml
関数型プログラミング入門 with OCaml
Haruka Oikawa
 
テスト文字列に「うんこ」と入れるな
テスト文字列に「うんこ」と入れるなテスト文字列に「うんこ」と入れるな
テスト文字列に「うんこ」と入れるな
Kentaro Matsui
 
どこに何を書くのか?
どこに何を書くのか?どこに何を書くのか?
どこに何を書くのか?
pospome
 
ふつうのRailsアプリケーション開発
ふつうのRailsアプリケーション開発ふつうのRailsアプリケーション開発
ふつうのRailsアプリケーション開発
Takafumi ONAKA
 
やはりお前らのMVCは間違っている
やはりお前らのMVCは間違っているやはりお前らのMVCは間違っている
やはりお前らのMVCは間違っている
Koichi Tanaka
 
serviceクラスをやめようサブクラスを使おう
serviceクラスをやめようサブクラスを使おうserviceクラスをやめようサブクラスを使おう
serviceクラスをやめようサブクラスを使おう
よしだ あつし
 
Effective modern c++ 8
Effective modern c++ 8Effective modern c++ 8
Effective modern c++ 8
uchan_nos
 
Controllerのbefore_actionにおける インスタンス変数セットについて
Controllerのbefore_actionにおける インスタンス変数セットについてControllerのbefore_actionにおける インスタンス変数セットについて
Controllerのbefore_actionにおける インスタンス変数セットについて
pospome
 
ユニットテストの保守性を作りこむ, xpjugkansai2011
ユニットテストの保守性を作りこむ, xpjugkansai2011ユニットテストの保守性を作りこむ, xpjugkansai2011
ユニットテストの保守性を作りこむ, xpjugkansai2011H Iseri
 
PHP初心者セッション2023 〜ChatGPT時代の簡単な始め方〜
PHP初心者セッション2023 〜ChatGPT時代の簡単な始め方〜PHP初心者セッション2023 〜ChatGPT時代の簡単な始め方〜
PHP初心者セッション2023 〜ChatGPT時代の簡単な始め方〜
Hideo Kashioka
 
HBaseを用いたグラフDB「Hornet」の設計と運用
HBaseを用いたグラフDB「Hornet」の設計と運用HBaseを用いたグラフDB「Hornet」の設計と運用
HBaseを用いたグラフDB「Hornet」の設計と運用
Toshihiro Suzuki
 
Laravelを用いたゲームサーバーのチューニング
Laravelを用いたゲームサーバーのチューニングLaravelを用いたゲームサーバーのチューニング
Laravelを用いたゲームサーバーのチューニング
NOW PRODUCTION
 
DeNA流Scrumとcommのチームビルディング
DeNA流ScrumとcommのチームビルディングDeNA流Scrumとcommのチームビルディング
DeNA流Scrumとcommのチームビルディング
Takeshi Kaise
 
pytest × TDD テスト駆動開発のススメ
pytest × TDD テスト駆動開発のススメpytest × TDD テスト駆動開発のススメ
pytest × TDD テスト駆動開発のススメ
iRidge, Inc.
 
オブジェクト指向エクササイズのススメ
オブジェクト指向エクササイズのススメオブジェクト指向エクササイズのススメ
オブジェクト指向エクササイズのススメYoji Kanno
 
JVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's TricksJVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's Tricks
Doug Hawkins
 
SECDマシン 実装と動きとその他もろもろについて
SECDマシン 実装と動きとその他もろもろについてSECDマシン 実装と動きとその他もろもろについて
SECDマシン 実装と動きとその他もろもろについて
t-sin
 
エラーハンドリング
エラーハンドリングエラーハンドリング
エラーハンドリング
道化師 堂華
 

What's hot (20)

F#によるFunctional Programming入門
F#によるFunctional Programming入門F#によるFunctional Programming入門
F#によるFunctional Programming入門
 
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
 
関数型プログラミング入門 with OCaml
関数型プログラミング入門 with OCaml関数型プログラミング入門 with OCaml
関数型プログラミング入門 with OCaml
 
テスト文字列に「うんこ」と入れるな
テスト文字列に「うんこ」と入れるなテスト文字列に「うんこ」と入れるな
テスト文字列に「うんこ」と入れるな
 
どこに何を書くのか?
どこに何を書くのか?どこに何を書くのか?
どこに何を書くのか?
 
ふつうのRailsアプリケーション開発
ふつうのRailsアプリケーション開発ふつうのRailsアプリケーション開発
ふつうのRailsアプリケーション開発
 
やはりお前らのMVCは間違っている
やはりお前らのMVCは間違っているやはりお前らのMVCは間違っている
やはりお前らのMVCは間違っている
 
serviceクラスをやめようサブクラスを使おう
serviceクラスをやめようサブクラスを使おうserviceクラスをやめようサブクラスを使おう
serviceクラスをやめようサブクラスを使おう
 
Effective modern c++ 8
Effective modern c++ 8Effective modern c++ 8
Effective modern c++ 8
 
Controllerのbefore_actionにおける インスタンス変数セットについて
Controllerのbefore_actionにおける インスタンス変数セットについてControllerのbefore_actionにおける インスタンス変数セットについて
Controllerのbefore_actionにおける インスタンス変数セットについて
 
ユニットテストの保守性を作りこむ, xpjugkansai2011
ユニットテストの保守性を作りこむ, xpjugkansai2011ユニットテストの保守性を作りこむ, xpjugkansai2011
ユニットテストの保守性を作りこむ, xpjugkansai2011
 
PHP初心者セッション2023 〜ChatGPT時代の簡単な始め方〜
PHP初心者セッション2023 〜ChatGPT時代の簡単な始め方〜PHP初心者セッション2023 〜ChatGPT時代の簡単な始め方〜
PHP初心者セッション2023 〜ChatGPT時代の簡単な始め方〜
 
HBaseを用いたグラフDB「Hornet」の設計と運用
HBaseを用いたグラフDB「Hornet」の設計と運用HBaseを用いたグラフDB「Hornet」の設計と運用
HBaseを用いたグラフDB「Hornet」の設計と運用
 
Laravelを用いたゲームサーバーのチューニング
Laravelを用いたゲームサーバーのチューニングLaravelを用いたゲームサーバーのチューニング
Laravelを用いたゲームサーバーのチューニング
 
DeNA流Scrumとcommのチームビルディング
DeNA流ScrumとcommのチームビルディングDeNA流Scrumとcommのチームビルディング
DeNA流Scrumとcommのチームビルディング
 
pytest × TDD テスト駆動開発のススメ
pytest × TDD テスト駆動開発のススメpytest × TDD テスト駆動開発のススメ
pytest × TDD テスト駆動開発のススメ
 
オブジェクト指向エクササイズのススメ
オブジェクト指向エクササイズのススメオブジェクト指向エクササイズのススメ
オブジェクト指向エクササイズのススメ
 
JVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's TricksJVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's Tricks
 
SECDマシン 実装と動きとその他もろもろについて
SECDマシン 実装と動きとその他もろもろについてSECDマシン 実装と動きとその他もろもろについて
SECDマシン 実装と動きとその他もろもろについて
 
エラーハンドリング
エラーハンドリングエラーハンドリング
エラーハンドリング
 

Recently uploaded

Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 

Recently uploaded (20)

Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 

明日から使えるRxjava頻出パターン (Droid kaigi 2016)