io.reactivex.Observable.blockingNext()方法的使用及代码示例

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

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

Observable.blockingNext介绍

[英]Returns an Iterable that blocks until this Observable emits another item, then returns that item.

Scheduler: blockingNext does not operate by default on a particular Scheduler.
[中]返回一个Iterable,该Iterable会阻塞,直到该可观察对象发出另一项,然后返回该项。
调度程序:blockingNext默认情况下不会在特定调度程序上运行。

代码示例

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Integer apply(Integer v) throws Exception {
    Observable.just(1).delay(10, TimeUnit.SECONDS).blockingNext().iterator().hasNext();
    return v;
  }
})

代码示例来源:origin: ReactiveX/RxJava

@Test
public void interrupt() {
  Iterator<Object> it = Observable.never().blockingNext().iterator();
  try {
    Thread.currentThread().interrupt();
    it.next();
  } catch (RuntimeException ex) {
    assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException);
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Test(expected = UnsupportedOperationException.class)
public void remove() {
  Observable.never().blockingNext().iterator().remove();
}

代码示例来源:origin: ReactiveX/RxJava

@Test /* (timeout = 8000) */
public void testSingleSourceManyIterators() throws InterruptedException {
  Observable<Long> o = Observable.interval(250, TimeUnit.MILLISECONDS);
  PublishSubject<Integer> terminal = PublishSubject.create();
  Observable<Long> source = o.takeUntil(terminal);
  Iterable<Long> iter = source.blockingNext();
  for (int j = 0; j < 3; j++) {
    BlockingObservableNext.NextIterator<Long> it = (BlockingObservableNext.NextIterator<Long>)iter.iterator();
    for (long i = 0; i < 10; i++) {
      Assert.assertEquals(true, it.hasNext());
      Assert.assertEquals(j + "th iteration next", Long.valueOf(i), it.next());
    }
    terminal.onNext(1);
  }
}

代码示例来源:origin: PacktPublishing/Learning-RxJava

@Test
  public void testBlockingNext() {
    Observable<Long> source =
        Observable.interval(1, TimeUnit.MICROSECONDS)
            .take(1000);
    Iterable<Long> iterable = source.blockingNext();
    for (Long i: iterable) {
      System.out.println(i);
    }
  }
}

代码示例来源:origin: PacktPublishing/Learning-RxJava

@Test
  public void testBlockingNext() {
    Observable<Long> source =
        Observable.interval(1, TimeUnit.MICROSECONDS)
            .take(1000);
    Iterable<Long> iterable = source.blockingNext();
    for (Long i: iterable) {
      System.out.println(i);
    }
  }
}

相关文章

Observable类方法