rx.Observable.skipLast()方法的使用及代码示例

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

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

Observable.skipLast介绍

[英]Returns an Observable that drops a specified number of items from the end of the sequence emitted by the source Observable.

This Observer 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 Observable. This causes such items to be delayed. Scheduler: This version of skipLast does not operate by default on a particular Scheduler.
[中]返回一个可观测项,该可观测项从源可观测项发出的序列末尾删除指定数量的项。
该观察者累积足够长的队列来存储第一个计数项。当接收到更多的项目时,项目将从队列的前端获取,并由返回的可观察对象发出。这会导致此类项目延迟。调度程序:默认情况下,此版本的skipLast不会在特定调度程序上运行。

代码示例

代码示例来源:origin: leeowenowen/rxjava-examples

@Override
 public void run() {
  Observable.range(1, 10).skipLast(3).subscribe(new Action1<Integer>() {
   @Override
   public void call(Integer integer) {
    log(integer);
   }
  });
 }
});

代码示例来源:origin: com.netflix.rxjava/rxjava-core

/**
 * Returns an Observable that drops items emitted by the source Observable during a specified time window
 * before the source completes.
 * <p>
 * <img width="640" height="305" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/skipLast.t.png" alt="">
 * <p>
 * Note: this action will cache the latest items arriving in the specified time window.
 * <dl>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>This version of {@code skipLast} operates by default on the {@code computation} {@link Scheduler}.</dd>
 * </dl>
 * 
 * @param time
 *            the length of the time window
 * @param unit
 *            the time unit of {@code time}
 * @return an Observable that drops those items emitted by the source Observable in a time window before the
 *         source completes defined by {@code time}
 * @see <a href="https://github.com/Netflix/RxJava/wiki/Filtering-Observables#skiplast">RxJava wiki: skipLast</a>
 * @see <a href="http://msdn.microsoft.com/en-us/library/hh211750.aspx">MSDN: Observable.SkipLast</a>
 */
public final Observable<T> skipLast(long time, TimeUnit unit) {
  return skipLast(time, unit, Schedulers.computation());
}

代码示例来源:origin: nurkiewicz/rxjava-book-examples

@Test
public void sample_531() throws Exception {
  Observable.range(1, 5).takeLast(2);  // [4, 5]
  Observable.range(1, 5).skipLast(2);  // [1, 2, 3]
}

相关文章

Observable类方法