本文整理了Java中io.reactivex.Flowable.timeInterval()
方法的一些代码示例,展示了Flowable.timeInterval()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flowable.timeInterval()
方法的具体详情如下:
包路径:io.reactivex.Flowable
类名称:Flowable
方法名:timeInterval
[英]Returns a Flowable that emits records of the time interval between consecutive items emitted by the source Publisher.
Backpressure: The operator doesn't interfere with backpressure which is determined by the source Publisher's backpressure behavior. Scheduler: timeInterval does not operate on any particular scheduler but uses the current time from the computation Scheduler.
[中]返回一个可流动项,该可流动项发出源发布服务器发出的连续项之间的时间间隔记录。
背压:操作员不会干扰由源发布者的背压行为确定的背压。调度器:timeInterval不在任何特定的调度器上运行,而是使用计算调度器中的当前时间。
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<Timed<Object>> apply(Flowable<Object> f)
throws Exception {
return f.timeInterval();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<Timed<Integer>> createPublisher(long elements) {
return
Flowable.range(0, (int)elements).timeInterval()
;
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void timeIntervalSchedulerNull() {
just1.timeInterval(TimeUnit.SECONDS, null);
}
代码示例来源:origin: ReactiveX/RxJava
/**
* Returns a Flowable that emits records of the time interval between consecutive items emitted by the
* source Publisher, where this interval is computed on a specified Scheduler.
* <p>
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/timeInterval.s.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator doesn't interfere with backpressure which is determined by the source {@code Publisher}'s backpressure
* behavior.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>The operator does not operate on any particular scheduler but uses the current time
* from the specified {@link Scheduler}.</dd>
* </dl>
*
* @param scheduler
* the {@link Scheduler} used to compute time intervals
* @return a Flowable that emits time interval information items
* @see <a href="http://reactivex.io/documentation/operators/timeinterval.html">ReactiveX operators documentation: TimeInterval</a>
*/
@CheckReturnValue
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
@SchedulerSupport(SchedulerSupport.NONE) // Supplied scheduler is only used for creating timestamps.
public final Flowable<Timed<T>> timeInterval(Scheduler scheduler) {
return timeInterval(TimeUnit.MILLISECONDS, scheduler);
}
代码示例来源:origin: ReactiveX/RxJava
/**
* Returns a Flowable that emits records of the time interval between consecutive items emitted by the
* source Publisher.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/timeInterval.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator doesn't interfere with backpressure which is determined by the source {@code Publisher}'s backpressure
* behavior.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code timeInterval} does not operate on any particular scheduler but uses the current time
* from the {@code computation} {@link Scheduler}.</dd>
* </dl>
*
* @return a Flowable that emits time interval information items
* @see <a href="http://reactivex.io/documentation/operators/timeinterval.html">ReactiveX operators documentation: TimeInterval</a>
*/
@CheckReturnValue
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<Timed<T>> timeInterval() {
return timeInterval(TimeUnit.MILLISECONDS, Schedulers.computation());
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void timeIntervalUnitNull() {
just1.timeInterval(null, Schedulers.single());
}
代码示例来源:origin: ReactiveX/RxJava
/**
* Returns a Flowable that emits records of the time interval between consecutive items emitted by the
* source Publisher.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/timeInterval.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator doesn't interfere with backpressure which is determined by the source {@code Publisher}'s backpressure
* behavior.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code timeInterval} does not operate on any particular scheduler but uses the current time
* from the {@code computation} {@link Scheduler}.</dd>
* </dl>
*
* @param unit the time unit for the current time
* @return a Flowable that emits time interval information items
* @see <a href="http://reactivex.io/documentation/operators/timeinterval.html">ReactiveX operators documentation: TimeInterval</a>
*/
@CheckReturnValue
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<Timed<T>> timeInterval(TimeUnit unit) {
return timeInterval(unit, Schedulers.computation());
}
代码示例来源:origin: redisson/redisson
/**
* Returns a Flowable that emits records of the time interval between consecutive items emitted by the
* source Publisher, where this interval is computed on a specified Scheduler.
* <p>
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/timeInterval.s.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator doesn't interfere with backpressure which is determined by the source {@code Publisher}'s backpressure
* behavior.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>The operator does not operate on any particular scheduler but uses the current time
* from the specified {@link Scheduler}.</dd>
* </dl>
*
* @param scheduler
* the {@link Scheduler} used to compute time intervals
* @return a Flowable that emits time interval information items
* @see <a href="http://reactivex.io/documentation/operators/timeinterval.html">ReactiveX operators documentation: TimeInterval</a>
*/
@CheckReturnValue
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
@SchedulerSupport(SchedulerSupport.NONE) // Supplied scheduler is only used for creating timestamps.
public final Flowable<Timed<T>> timeInterval(Scheduler scheduler) {
return timeInterval(TimeUnit.MILLISECONDS, scheduler);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void dispose() {
TestHelper.checkDisposed(Flowable.just(1).timeInterval());
}
代码示例来源:origin: redisson/redisson
/**
* Returns a Flowable that emits records of the time interval between consecutive items emitted by the
* source Publisher.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/timeInterval.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator doesn't interfere with backpressure which is determined by the source {@code Publisher}'s backpressure
* behavior.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code timeInterval} does not operate on any particular scheduler but uses the current time
* from the {@code computation} {@link Scheduler}.</dd>
* </dl>
*
* @param unit the time unit for the current time
* @return a Flowable that emits time interval information items
* @see <a href="http://reactivex.io/documentation/operators/timeinterval.html">ReactiveX operators documentation: TimeInterval</a>
*/
@CheckReturnValue
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<Timed<T>> timeInterval(TimeUnit unit) {
return timeInterval(unit, Schedulers.computation());
}
代码示例来源:origin: redisson/redisson
/**
* Returns a Flowable that emits records of the time interval between consecutive items emitted by the
* source Publisher.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/timeInterval.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator doesn't interfere with backpressure which is determined by the source {@code Publisher}'s backpressure
* behavior.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code timeInterval} does not operate on any particular scheduler but uses the current time
* from the {@code computation} {@link Scheduler}.</dd>
* </dl>
*
* @return a Flowable that emits time interval information items
* @see <a href="http://reactivex.io/documentation/operators/timeinterval.html">ReactiveX operators documentation: TimeInterval</a>
*/
@CheckReturnValue
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<Timed<T>> timeInterval() {
return timeInterval(TimeUnit.MILLISECONDS, Schedulers.computation());
}
代码示例来源:origin: ReactiveX/RxJava
@SuppressWarnings("unchecked")
@Test
public void error() {
Flowable.error(new TestException())
.timeInterval()
.test()
.assertFailure(TestException.class);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void timeIntervalDefault() {
final TestScheduler scheduler = new TestScheduler();
RxJavaPlugins.setComputationSchedulerHandler(new Function<Scheduler, Scheduler>() {
@Override
public Scheduler apply(Scheduler v) throws Exception {
return scheduler;
}
});
try {
Flowable.range(1, 5)
.timeInterval()
.map(new Function<Timed<Integer>, Long>() {
@Override
public Long apply(Timed<Integer> v) throws Exception {
return v.time();
}
})
.test()
.assertResult(0L, 0L, 0L, 0L, 0L);
} finally {
RxJavaPlugins.reset();
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void timeIntervalDefaultSchedulerCustomUnit() {
final TestScheduler scheduler = new TestScheduler();
RxJavaPlugins.setComputationSchedulerHandler(new Function<Scheduler, Scheduler>() {
@Override
public Scheduler apply(Scheduler v) throws Exception {
return scheduler;
}
});
try {
Flowable.range(1, 5)
.timeInterval(TimeUnit.SECONDS)
.map(new Function<Timed<Integer>, Long>() {
@Override
public Long apply(Timed<Integer> v) throws Exception {
return v.time();
}
})
.test()
.assertResult(0L, 0L, 0L, 0L, 0L);
} finally {
RxJavaPlugins.reset();
}
}
内容来源于网络,如有侵权,请联系作者删除!