本文整理了Java中io.reactivex.Observable.blockingMostRecent()
方法的一些代码示例,展示了Observable.blockingMostRecent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.blockingMostRecent()
方法的具体详情如下:
包路径:io.reactivex.Observable
类名称:Observable
方法名:blockingMostRecent
[英]Returns an Iterable that always returns the item most recently emitted by this Observable.
Scheduler: blockingMostRecent does not operate by default on a particular Scheduler.
[中]返回一个Iterable,它总是返回此可观察对象最近发出的项。
调度程序:blockingMostRecent默认情况下不会在特定调度程序上运行。
代码示例来源:origin: ReactiveX/RxJava
static <T> Iterable<T> mostRecent(Observable<T> source, T initialValue) {
return source.blockingMostRecent(initialValue);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testMostRecentNull() {
assertEquals(null, Observable.<Void>never().blockingMostRecent(null).iterator().next());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void empty() {
Iterator<Integer> it = Observable.<Integer>empty()
.blockingMostRecent(1)
.iterator();
try {
it.next();
fail("Should have thrown");
} catch (NoSuchElementException ex) {
// expected
}
try {
it.remove();
fail("Should have thrown");
} catch (UnsupportedOperationException ex) {
// expected
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test(timeout = 1000)
public void testSingleSourceManyIterators() {
TestScheduler scheduler = new TestScheduler();
Observable<Long> source = Observable.interval(1, TimeUnit.SECONDS, scheduler).take(10);
Iterable<Long> iter = source.blockingMostRecent(-1L);
for (int j = 0; j < 3; j++) {
Iterator<Long> it = iter.iterator();
Assert.assertEquals(Long.valueOf(-1), it.next());
for (int i = 0; i < 9; i++) {
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
Assert.assertEquals(true, it.hasNext());
Assert.assertEquals(Long.valueOf(i), it.next());
}
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
Assert.assertEquals(false, it.hasNext());
}
}
代码示例来源:origin: PacktPublishing/Learning-RxJava
@Test
public void testBlockingMostRecent() {
Observable<Long> source =
Observable.interval(10, TimeUnit.MILLISECONDS)
.take(5);
Iterable<Long> iterable = source.blockingMostRecent(-1L);
for (Long i: iterable) {
System.out.println(i);
}
}
}
代码示例来源:origin: PacktPublishing/Learning-RxJava
@Test
public void testBlockingMostRecent() {
Observable<Long> source =
Observable.interval(10, TimeUnit.MILLISECONDS)
.take(5);
Iterable<Long> iterable = source.blockingMostRecent(-1L);
for (Long i: iterable) {
System.out.println(i);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!