rx.Observable.all()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(210)

本文整理了Java中rx.Observable.all()方法的一些代码示例,展示了Observable.all()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.all()方法的具体详情如下:
包路径:rx.Observable
类名称:Observable
方法名:all

Observable.all介绍

[英]Returns an Observable that emits a Boolean that indicates whether all of the items emitted by the source Observable satisfy a condition.

Scheduler: all does not operate by default on a particular Scheduler.
[中]返回一个Observable,该Observable发出一个布尔值,指示源Observable发出的所有项是否满足条件。
调度器:默认情况下,all不会在特定的调度器上运行。

代码示例

代码示例来源:origin: leeowenowen/rxjava-examples

@Override
 public void run() {
  Observable.just(2, 4, 6).all(new Func1<Integer, Boolean>() {
   @Override
   public Boolean call(Integer integer) {
    return integer % 2 == 0;
   }
  }).subscribe(new Action1<Boolean>() {
   @Override
   public void call(Boolean aBoolean) {
    log(aBoolean);
   }
  });
 }
});

代码示例来源:origin: henrymorgen/android-advanced-light

private void all() {
    Observable.just(1,2,3)
        .all(new Func1<Integer, Boolean>() {
          @Override
          public Boolean call(Integer integer) {
            Log.d(TAG, "call:"+integer);
            return integer<2;
          }
        }).subscribe(new Subscriber<Boolean>() {
      @Override
      public void onCompleted() {
        Log.d(TAG, "onCompleted");
      }
      @Override
      public void onError(Throwable e) {
        Log.d(TAG, "onError:"+e.getMessage());
      }
      @Override
      public void onNext(Boolean aBoolean) {
        Log.d(TAG, "onNext:"+aBoolean);
      }
    });
  }
}

代码示例来源:origin: OpenNMS/newts

private Observable<Boolean> directPoster(Observable<List<Sample>> samples, MetricRegistry metrics) {
  final SampleRepository repository = repository();
  final Timer timer = metrics.timer("writes");
  final Meter completions = metrics.meter("samples-completed");
  
  Func1<List<Sample>, Boolean> insert = new Func1<List<Sample>, Boolean>() {
    @Override
    public Boolean call(List<Sample> s) {
      int sz = s.size();
      try (Context timerCtx = timer.time()) {
        repository.insert(s);
        return true;
      } finally {
        completions.mark(sz);
      }
    }
  };
  
  
  return (m_threadCount == 1 ? samples.map(insert) : parMap(samples, metrics, insert)).all(Functions.<Boolean>identity());
  
  
}

代码示例来源:origin: OpenNMS/newts

.all(successful())

代码示例来源:origin: com.netflix.rxjava/rxjava-core

}).all(Functions.<Boolean> identity());

代码示例来源:origin: nurkiewicz/rxjava-book-examples

@Test
public void sample_550() throws Exception {
  Observable<Integer> numbers = Observable.range(1, 5);
  numbers.all(x -> x != 4);    // [false]
  numbers.exists(x -> x == 4); // [true]
  numbers.contains(4);         // [true]
}

相关文章

Observable类方法