本文整理了Java中rx.Observable.timeInterval()
方法的一些代码示例,展示了Observable.timeInterval()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.timeInterval()
方法的具体详情如下:
包路径:rx.Observable
类名称:Observable
方法名:timeInterval
[英]Returns an Observable that emits records of the time interval between consecutive items emitted by the source Observable.
Scheduler: timeInterval operates by default on the immediate Scheduler.
[中]返回一个Observable,该Observable发出源Observable发出的连续项之间的时间间隔记录。
调度器:默认情况下,timeInterval在即时调度器上运行。
代码示例来源:origin: com.netflix.rxjava/rxjava-core
/**
* Returns an Observable that emits records of the time interval between consecutive items emitted by the
* source Observable.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/timeInterval.png" alt="">
* <dl>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code timeInterval} operates by default on the {@code immediate} {@link Scheduler}.</dd>
* </dl>
*
* @return an Observable that emits time interval information items
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable-Utility-Operators#timeinterval">RxJava wiki: timeInterval</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/hh212107.aspx">MSDN: Observable.TimeInterval</a>
*/
public final Observable<TimeInterval<T>> timeInterval() {
return timeInterval(Schedulers.immediate());
}
代码示例来源:origin: leeowenowen/rxjava-examples
@Override
public void run() {
Observable.create(new Observable.OnSubscribe<Integer>() {
@Override
public void call(Subscriber<? super Integer> subscriber) {
subscriber.onNext(1);
sleep(1000);
subscriber.onNext(2);
subscriber.onCompleted();
}
})
.subscribeOn(Schedulers.newThread())
.timeInterval()
.subscribe(new Action1<TimeInterval<Integer>>() {
@Override
public void call(TimeInterval<Integer> integerTimeInterval) {
log("" + integerTimeInterval.getValue() + " " +
integerTimeInterval.getIntervalInMilliseconds());
}
});
}
});
代码示例来源:origin: nurkiewicz/rxjava-book-examples
@Test
public void sample_262() throws Exception {
Observable<TimeInterval<LocalDate>> intervals =
nextSolarEclipse(LocalDate.of(2016, JANUARY, 1))
.timeInterval();
}
内容来源于网络,如有侵权,请联系作者删除!