本文整理了Java中io.reactivex.Flowable.skipLast()
方法的一些代码示例,展示了Flowable.skipLast()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flowable.skipLast()
方法的具体详情如下:
包路径:io.reactivex.Flowable
类名称:Flowable
方法名:skipLast
[英]Returns a Flowable that drops a specified number of items from the end of the sequence emitted by the source Publisher.
This Subscriber accumulates a queue long enough to store the first count items. As more items are received, items are taken from the front of the queue and emitted by the returned Publisher. This causes such items to be delayed. Backpressure: The operator doesn't interfere with backpressure which is determined by the source Publisher's backpressure behavior. Scheduler: This version of skipLast does not operate by default on a particular Scheduler.
[中]返回从源发布服务器发出的序列末尾删除指定数量项的可流动项。
此订阅服务器累积足够长的队列以存储第一个计数项目。当接收到更多的项目时,项目将从队列前面获取,并由返回的发布服务器发出。这会导致此类项目延迟。背压:操作员不会干扰由源发布者的背压行为确定的背压。调度程序:默认情况下,此版本的skipLast不会在特定调度程序上运行。
代码示例来源:origin: ReactiveX/RxJava
@Override
public Flowable<Object> apply(Flowable<Object> f)
throws Exception {
return f.skipLast(1);
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public Flowable<Object> apply(Flowable<Object> f) throws Exception {
return f.skipLast(1, TimeUnit.DAYS);
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<Integer> createPublisher(long elements) {
return
Flowable.range(0, (int)elements * 2).skipLast((int)elements)
;
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void skipLastTimedSchedulerNull() {
just1.skipLast(1, TimeUnit.SECONDS, null);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testSkipLast1() {
Flowable<String> flowable = Flowable.fromIterable(Arrays.asList("one", "two", "three")).skipLast(2);
Subscriber<String> subscriber = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(subscriber);
flowable.subscribe(subscriber);
inOrder.verify(subscriber, never()).onNext("two");
inOrder.verify(subscriber, never()).onNext("three");
verify(subscriber, times(1)).onNext("one");
verify(subscriber, never()).onError(any(Throwable.class));
verify(subscriber, times(1)).onComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testSkipLast2() {
Flowable<String> flowable = Flowable.fromIterable(Arrays.asList("one", "two")).skipLast(2);
Subscriber<String> subscriber = TestHelper.mockSubscriber();
flowable.subscribe(subscriber);
verify(subscriber, never()).onNext(any(String.class));
verify(subscriber, never()).onError(any(Throwable.class));
verify(subscriber, times(1)).onComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = IndexOutOfBoundsException.class)
public void testSkipLastWithNegativeCount() {
Flowable.just("one").skipLast(-1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void skipLastTimedUnitNull() {
just1.skipLast(1, null, Schedulers.single());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testSkipLastEmpty() {
Flowable<String> flowable = Flowable.<String> empty().skipLast(2);
Subscriber<String> subscriber = TestHelper.mockSubscriber();
flowable.subscribe(subscriber);
verify(subscriber, never()).onNext(any(String.class));
verify(subscriber, never()).onError(any(Throwable.class));
verify(subscriber, times(1)).onComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
@Ignore("Null values not allowed")
public void testSkipLastWithNull() {
Flowable<String> flowable = Flowable.fromIterable(Arrays.asList("one", null, "two")).skipLast(1);
Subscriber<String> subscriber = TestHelper.mockSubscriber();
flowable.subscribe(subscriber);
verify(subscriber, times(1)).onNext("one");
verify(subscriber, times(1)).onNext(null);
verify(subscriber, never()).onNext("two");
verify(subscriber, never()).onError(any(Throwable.class));
verify(subscriber, times(1)).onComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testSkipLastWithZeroCount() {
Flowable<String> w = Flowable.just("one", "two");
Flowable<String> flowable = w.skipLast(0);
Subscriber<String> subscriber = TestHelper.mockSubscriber();
flowable.subscribe(subscriber);
verify(subscriber, times(1)).onNext("one");
verify(subscriber, times(1)).onNext("two");
verify(subscriber, never()).onError(any(Throwable.class));
verify(subscriber, times(1)).onComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void dispose() {
TestHelper.checkDisposed(Flowable.just(1).skipLast(1));
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void error() {
Flowable.error(new TestException())
.skipLast(1)
.test()
.assertFailure(TestException.class);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void skipLastTimedCustomSchedulerDelayError() {
Flowable.just(1).concatWith(Flowable.just(2).delay(500, TimeUnit.MILLISECONDS))
.skipLast(300, TimeUnit.MILLISECONDS, Schedulers.io(), true)
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void take() {
Flowable.just(1)
.skipLast(0, TimeUnit.SECONDS)
.take(1)
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void errorDelayed() {
Flowable.error(new TestException())
.skipLast(1, TimeUnit.DAYS, new TestScheduler(), true)
.test()
.assertFailure(TestException.class);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void skipLastTimedDefaultScheduler() {
Flowable.just(1).concatWith(Flowable.just(2).delay(500, TimeUnit.MILLISECONDS))
.skipLast(300, TimeUnit.MILLISECONDS)
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void skipLastTimedDefaultSchedulerDelayError() {
Flowable.just(1).concatWith(Flowable.just(2).delay(500, TimeUnit.MILLISECONDS))
.skipLast(300, TimeUnit.MILLISECONDS, true)
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void observeOn() {
Flowable.range(1, 1000)
.skipLast(0, TimeUnit.SECONDS)
.observeOn(Schedulers.single(), false, 16)
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertSubscribed()
.assertValueCount(1000)
.assertComplete()
.assertNoErrors();
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testSkipLastWithBackpressure() {
Flowable<Integer> f = Flowable.range(0, Flowable.bufferSize() * 2).skipLast(Flowable.bufferSize() + 10);
TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
f.observeOn(Schedulers.computation()).subscribe(ts);
ts.awaitTerminalEvent();
ts.assertNoErrors();
assertEquals((Flowable.bufferSize()) - 10, ts.valueCount());
}
内容来源于网络,如有侵权,请联系作者删除!