io.reactivex.Observable.throttleLast()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中io.reactivex.Observable.throttleLast()方法的一些代码示例,展示了Observable.throttleLast()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.throttleLast()方法的具体详情如下:
包路径:io.reactivex.Observable
类名称:Observable
方法名:throttleLast

Observable.throttleLast介绍

[英]Returns an Observable that emits only the last item emitted by the source ObservableSource 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.

Scheduler: throttleLast operates by default on the computation Scheduler.
[中]返回在指定持续时间的连续时间窗口内仅发射源ObservableSource发射的最后一项的Observable。
这与#throttleFirst的不同之处在于,它会按预定的间隔滴答作响,而#throttleFirst不会滴答作响,它只是跟踪时间的流逝。
调度器:throttleLast默认在计算调度器上运行。

代码示例

代码示例来源:origin: amitshekhariitbhu/RxJava2-Android-Samples

private void doSomeWork() {
  getObservable()
      .throttleLast(500, TimeUnit.MILLISECONDS)
      // Run on a background thread
      .subscribeOn(Schedulers.io())
      // Be notified on the main thread
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(getObserver());
}

代码示例来源:origin: ReactiveX/RxJava

@Test(expected = NullPointerException.class)
public void throttleLastSchedulerNull() {
  just1.throttleLast(1, TimeUnit.SECONDS, null);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testSampleUnsubscribe() {
  final Disposable upstream = mock(Disposable.class);
  Observable<Integer> o = Observable.unsafeCreate(
      new ObservableSource<Integer>() {
        @Override
        public void subscribe(Observer<? super Integer> observer) {
          observer.onSubscribe(upstream);
        }
      }
  );
  o.throttleLast(1, TimeUnit.MILLISECONDS).subscribe().dispose();
  verify(upstream).dispose();
}

代码示例来源:origin: ReactiveX/RxJava

@Test(expected = NullPointerException.class)
public void throttleLastUnitNull() {
  just1.throttleLast(1, null, Schedulers.single());
}

代码示例来源:origin: zhiwei1990/android-jetpack-demo

public static void doSome() {
  getObservable()
      .throttleLast(500, TimeUnit.MILLISECONDS)
      .subscribeOn(Schedulers.io())
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(getObserver(TAG, ""));
}

相关文章

Observable类方法