本文整理了Java中rx.Observable.throttleLast()
方法的一些代码示例,展示了Observable.throttleLast()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.throttleLast()
方法的具体详情如下:
包路径:rx.Observable
类名称:Observable
方法名:throttleLast
[英]Returns an Observable that emits only the last item emitted by the source Observable during sequential time windows of a specified duration.
This differs from #throttleFirst in that this ticks along at a scheduled interval whereas #throttleFirst does not tick, it just tracks passage of time.
Backpressure Support: This operator does not support backpressure as it uses time to control data flow. Scheduler: throttleLast operates by default on the computation Scheduler.
[中]返回在指定持续时间的连续时间窗口内仅发射源可观测项发射的最后一项的可观测项。
这与#throttleFirst的不同之处在于,它会按预定的间隔滴答作响,而#throttleFirst不会滴答作响,它只是跟踪时间的流逝。
背压支持:该操作员不支持背压,因为它使用时间来控制数据流。调度器:throttleLast默认在计算调度器上运行。
代码示例来源:origin: BaronZ88/MinimalistWeather
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_search) {
SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
RxSearchView.queryTextChanges(searchView)
.map(charSequence -> charSequence == null ? null : charSequence.toString().trim())
.throttleLast(100, TimeUnit.MILLISECONDS)
.debounce(100, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(searchText -> selectCityFragment.cityListAdapter.getFilter().filter(searchText));
return true;
}
return super.onOptionsItemSelected(item);
}
代码示例来源:origin: jhusain/learnrxjava
public static void main(String args[]) {
// first item emitted in each time window
hotStream().throttleFirst(500, TimeUnit.MILLISECONDS).take(10).toBlocking().forEach(System.out::println);
// last item emitted in each time window
hotStream().throttleLast(500, TimeUnit.MILLISECONDS).take(10).toBlocking().forEach(System.out::println);
}
代码示例来源:origin: leeowenowen/rxjava-examples
@Override
public void run() {
final Subscription subscription = Observable.create(new Observable.OnSubscribe<Integer>() {
@Override
public void call(Subscriber<? super Integer> subscriber) {
for (int i = 0; i < 5; i++) {
subscriber.onNext(i);
sleep(300);
}
}
}).throttleLast(1, TimeUnit.SECONDS).subscribe(new Action1<Integer>() {
@Override
public void call(Integer integer) {
log(integer);
}
});
}
});
内容来源于网络,如有侵权,请联系作者删除!