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


Java Flowable.concat方法代码示例

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


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

示例1: concatWith

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
@SafeVarargs
public final DataStream<T> concatWith(DataStream<T>... streams) {
  Objects.requireNonNull(streams, NULL_STREAMS_MESSAGE);
  List<DataStream<T>> list = new ArrayList<>();
  list.add(this);
  list.addAll(Arrays.asList(streams));

  Flowable<Data<T>> merged = Flowable.concat(list.stream()
    .map(DataStream::flow)
    .collect(Collectors.toList())
  );

  List<DataStream> previous = new ArrayList<>();
  previous.add(this);
  previous.addAll(Arrays.asList(streams));

  DataStreamImpl<Object, T> next = new DataStreamImpl<>(previous, merged);
  this.setDownstreams(next);
  Arrays.stream(streams).forEach(d -> d.setDownstreams(next));

  return next;
}
 
开发者ID:cescoffier,项目名称:fluid,代码行数:24,代码来源:DataStreamImpl.java

示例2: getOne

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Flowable<Optional<T>> getOne(final Filter filter, final SortingMode sortingMode) {
    List<Flowable<Optional<T>>> flowables = new ArrayList<>();
    Flowable<Optional<T>> flowStorage = dao.getOne(filter, sortingMode);

    if(hasSyncedStore()) {
        flowStorage = flowStorage
                .flatMap(new Function<Optional<T>, Flowable<Optional<T>>>() {
                    @Override
                    public Flowable<Optional<T>> apply(Optional<T> item) throws Exception {
                        return syncedStore.insertOrUpdate(item.get());
                    }
                });

        flowables.add(syncedStore.getOne(filter, sortingMode));
    }

    flowables.add(flowStorage);
    return Flowable.concat(flowables);
}
 
开发者ID:playmoweb,项目名称:store2store,代码行数:21,代码来源:StoreService.java

示例3: getById

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Flowable<Optional<T>> getById(final int id) {
    List<Flowable<Optional<T>>> flowables = new ArrayList<>();
    Flowable<Optional<T>> flowStorage = dao.getById(id);

    if(hasSyncedStore()) {
        flowStorage = flowStorage
                .flatMap(new Function<Optional<T>, Flowable<Optional<T>>>() {
                    @Override
                    public Flowable<Optional<T>> apply(final Optional<T> item) throws Exception {
                        return syncedStore.insertOrUpdate(item.get());
                    }
                });

        flowables.add(syncedStore.getById(id));
    }

    flowables.add(flowStorage);
    return Flowable.concat(flowables);
}
 
开发者ID:playmoweb,项目名称:store2store,代码行数:21,代码来源:StoreService.java

示例4: delete

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Flowable<Integer> delete(final List<T> items) {
    List<Flowable<Integer>> flowables = new ArrayList<>();
    Flowable<Integer> flowStorage = dao.delete(items);

    if(hasSyncedStore()) {
        flowStorage = flowStorage
                .onErrorResumeNext(new Function<Throwable, Flowable<Integer>>() {
                    @Override
                    public Flowable<Integer> apply(final Throwable throwable) throws Exception {
                        return syncedStore.insertOrUpdate(items)
                                .flatMap(new Function<Optional<List<T>>, Flowable<Integer>>() {
                                    @Override
                                    public Flowable<Integer> apply(Optional<List<T>> reinsertedItem) throws Exception {
                                        return Flowable.error(throwable);
                                    }
                                });
                    }
                });

        flowables.add(syncedStore.delete(items));
    }

    flowables.add(flowStorage);
    return Flowable.concat(flowables);
}
 
开发者ID:playmoweb,项目名称:store2store,代码行数:27,代码来源:StoreService.java

示例5: insert

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Flowable<Optional<List<T>>> insert(final List<T> items) {
    List<Flowable<Optional<List<T>>>> flowables = new ArrayList<>();
    Flowable<Optional<List<T>>> flowStorage = dao.insert(items);

    if(hasSyncedStore()) {
        flowStorage = flowStorage
                .onErrorResumeNext(new Function<Throwable, Flowable<Optional<List<T>>>>() {
                    @Override
                    public Flowable<Optional<List<T>>> apply(final Throwable throwable) throws Exception {
                        return syncedStore.delete(items).flatMap(new Function<Object, Flowable<Optional<List<T>>>>() {
                            @Override
                            public Flowable<Optional<List<T>>> apply(Object o) throws Exception {
                                return Flowable.error(throwable);
                            }
                        });
                    }
                })
                .flatMap(new Function<Optional<List<T>>, Flowable<Optional<List<T>>>>() {
                    @Override
                    public Flowable<Optional<List<T>>> apply(Optional<List<T>> it) throws Exception {
                        return syncedStore.insertOrUpdate(it.get());
                    }
                });

        flowables.add(syncedStore.insert(items));
    }

    flowables.add(flowStorage);
    return Flowable.concat(flowables);
}
 
开发者ID:playmoweb,项目名称:store2store,代码行数:32,代码来源:StoreService.java

示例6: deleteAll

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Flowable<Integer> deleteAll() {
    List<Flowable<Integer>> flowables = new ArrayList<>();
    Flowable<Integer> flowStorage = dao.deleteAll();

    // TODO improve the deleteAll method in case of double fail
    // copy the syncedStore for insert if double fail
    // execute the deleteAll (this)
    // if error, try getAll()
    // if error again => re-insert syncedStore datas (better than nothing)
    // if not error, insert fresh datas

    if(hasSyncedStore()) {
        flowStorage = flowStorage
                .onErrorResumeNext(new Function<Throwable, Flowable<Integer>>() {
                    @Override
                    public Flowable<Integer> apply(final Throwable throwable) throws Exception {
                        return dao.getAll(null, null)
                                .flatMap(new Function<Optional<List<T>>, Flowable<Optional<List<T>>>>() {
                                    @Override
                                    public Flowable<Optional<List<T>>> apply(final Optional<List<T>> items) throws Exception {
                                        return syncedStore.insertOrUpdate(items.get());
                                    }
                                })
                                .flatMap(new Function<Optional<List<T>>, Flowable<Integer>>() {
                                    @Override
                                    public Flowable<Integer> apply(Optional<List<T>> reinsertedItems) throws Exception {
                                        return Flowable.error(throwable);
                                    }
                                });
                    }
                });

        flowables.add(syncedStore.deleteAll());
    }

    flowables.add(flowStorage);
    return Flowable.concat(flowables);
}
 
开发者ID:playmoweb,项目名称:store2store,代码行数:40,代码来源:StoreService.java


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