本文整理汇总了Java中io.reactivex.Single.map方法的典型用法代码示例。如果您正苦于以下问题:Java Single.map方法的具体用法?Java Single.map怎么用?Java Single.map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.Single
的用法示例。
在下文中一共展示了Single.map方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import io.reactivex.Single; //导入方法依赖的package包/类
private static Single<TmpResult> init(Single<Entry> single) {
return single.map(entry -> {
TmpResult result = new TmpResult(entry.getId(), entry.getAccountId(), entry.count());
FullAndNonFullUpdates updates = entry.getUpdates();
if (updates.hasFullMessages()) {
for (AddMessageUpdate update : updates.getFullMessages()) {
result.add(update.getMessageId())
.setDto(Dto2Model.transform(entry.getAccountId(), update));
}
}
if (updates.hasNonFullMessages()) {
for (Integer id : updates.getNonFull()) {
result.add(id);
}
}
return result;
});
}
示例2: getForecast
import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<Channel> getForecast(final String location) {
// TODO escape location
String yql = String.format(GET_FORECAST_FORMAT_STR, location);
Single<Response<WeatherResponse>> single = weatherService.getByYql(yql);
return single.map(new Function<Response<WeatherResponse>, Channel>() {
@Override
public Channel apply(Response<WeatherResponse> response) throws Exception {
Results results = response.body().getQuery().getResults();
if (results == null) {
throw new LocationNotFoundError(location);
}
return results.getChannel();
}
});
}
示例3: getPlaylistsBy
import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<List<PlaylistEntity>> getPlaylistsBy(List<String> categories) {
if(categories!=null) {
Single<List<PlaylistEntity>> start = Single.just(new LinkedList<>());
for(String category:categories){
start=Single.zip(start,service.searchPlaylists(PlaylistEntity
.Filter.start()
.byName(category)
.limit(100)
.createOptions())
.onErrorResumeNext(Single.just(new ArrayList<>())),(first,second)->{
if(second!=null){
first.addAll(second);
}
return first;
});
}
return start.map(filter::filterPlaylists);
}
return Single.error(new IllegalArgumentException("categories are null"));
}
示例4: getTracksBy
import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<List<TrackEntity>> getTracksBy(List<String> categories) {
if(categories!=null) {
Single<List<TrackEntity>> start = Single.just(new LinkedList<>());
for(String category:categories){
start=Single.zip(start,service.searchTracks(TrackEntity
.Filter.start()
.byTags(category)
.createOptions())
.onErrorResumeNext(Single.just(new ArrayList<>())),(first,second)->{
if(second!=null){
first.addAll(second);
}
return first;
});
}
return start.map(filter::filterTracks);
}
return Single.error(new IllegalArgumentException("categories are null"));
}
示例5: from
import io.reactivex.Single; //导入方法依赖的package包/类
/**
* Create a new step with a single that always returns a value.
*
* @param stepDataSingle - a single that returns a result for this step.
* @param <T> type of return value (if any) for this step.
* @param <A> type of {@link ActionableItem} this step returns when finished
* @return a new {@link Step}.
*/
public static <T, A extends ActionableItem> Step<T, A> from(Single<Data<T, A>> stepDataSingle) {
return new Step<>(
stepDataSingle.map(
new Function<Data<T, A>, Optional<Data<T, A>>>() {
@Override
public Optional<Data<T, A>> apply(Data<T, A> data) throws Exception {
return Optional.of(data);
}
}));
}
示例6: apply
import io.reactivex.Single; //导入方法依赖的package包/类
@Override public SingleSource<Optional<T>> apply(Single<DataSnapshot> upstream) {
return upstream.map(new Function<DataSnapshot, Optional<T>>() {
@Override public Optional<T> apply(DataSnapshot dataSnapshot) throws Exception {
return Optional.of(dataSnapshot.getValue(clazz));
}
});
}
示例7: apply
import io.reactivex.Single; //导入方法依赖的package包/类
@Override public SingleSource<Optional<T>> apply(Single<DataSnapshot> upstream) {
return upstream.map(new Function<DataSnapshot, Optional<T>>() {
@Override public Optional<T> apply(DataSnapshot dataSnapshot) throws Exception {
return Optional.of(dataSnapshot.getValue(typeIndicator));
}
});
}
示例8: postMessage
import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<Empty> postMessage(Single<ChatProto.ChatMessage> request) {
return request.map(this::broadcast);
}
示例9: oneToOne
import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<Message> oneToOne(Single<Message> request) {
return request.map(this::maybeExplode);
}