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

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

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

Observable.onBackpressureLatest介绍

暂无

代码示例

代码示例来源:origin: davidmoten/rxjava-extras

private static <Out> Observable<Notification<Out>> applyBackpressure(
    Observable<Notification<Out>> o, final BackpressureStrategy backpressureStrategy) {
  if (backpressureStrategy == BackpressureStrategy.BUFFER)
    return o.onBackpressureBuffer();
  else if (backpressureStrategy == BackpressureStrategy.DROP)
    return o.onBackpressureDrop();
  else if (backpressureStrategy == BackpressureStrategy.LATEST)
    return o.onBackpressureLatest();
  else
    throw new IllegalArgumentException(
        "backpressure strategy not supported: " + backpressureStrategy);
}

代码示例来源:origin: hotchemi/tiamat

Preference(SharedPreferences preferences, final String key, T defValue, Proxy<T> proxy, Observable<String> keyChanges) {
  this.preferences = preferences;
  this.key = key;
  this.defValue = defValue;
  this.proxy = proxy;
  this.values = keyChanges
      .filter(new Func1<String, Boolean>() {
        @Override
        public Boolean call(String changedKey) {
          return key.equals(changedKey);
        }
      })
      .startWith("") // to trigger initial load
      .onBackpressureLatest()
      .map(new Func1<String, T>() {
        @Override
        public T call(String ignored) {
          return asValue();
        }
      });
}

代码示例来源:origin: com.github.davidmoten/rxjava-extras

private static <Out> Observable<Notification<Out>> applyBackpressure(
    Observable<Notification<Out>> o, final BackpressureStrategy backpressureStrategy) {
  if (backpressureStrategy == BackpressureStrategy.BUFFER)
    return o.onBackpressureBuffer();
  else if (backpressureStrategy == BackpressureStrategy.DROP)
    return o.onBackpressureDrop();
  else if (backpressureStrategy == BackpressureStrategy.LATEST)
    return o.onBackpressureLatest();
  else
    throw new IllegalArgumentException(
        "backpressure strategy not supported: " + backpressureStrategy);
}

代码示例来源:origin: Petikoch/Java_MVVM_with_Swing_and_RxJava_Examples

public void toSwingViewEnabledPropertyOf(JComponent target) {
    source.onBackpressureLatest()
        .observeOn(SwingScheduler.getInstance())
        .lift(preserveFullStackTrace())
        .subscribe(target::setEnabled);
  }
}

代码示例来源:origin: Petikoch/Java_MVVM_with_Swing_and_RxJava_Examples

public void toSwingViewText(JTextComponent target) {
  source.onBackpressureLatest()
      .observeOn(SwingScheduler.getInstance())
      .lift(preserveFullStackTrace())
      .subscribe(target::setText);
}

代码示例来源:origin: Petikoch/Java_MVVM_with_Swing_and_RxJava_Examples

public void toSwingViewLabel(JLabel target) {
    source.onBackpressureLatest()
        .observeOn(SwingScheduler.getInstance())
        .lift(preserveFullStackTrace())
        .subscribe(target::setText);
  }
}

代码示例来源:origin: nvanbenschoten/RxSensor

.onBackpressureLatest();

代码示例来源:origin: akarnokd/akarnokd-misc

public static void main(String[] args) {
    System.out.println(Observable.interval(1, 1, TimeUnit.MILLISECONDS)
    .take(2000)
    .share()
    .onBackpressureLatest()
    .subscribeOn(Schedulers.io())
    .observeOn(Schedulers.computation(), 16)
    .doOnNext(System.out::println)
    .toList()
    .toBlocking()
    .last().size());
  }
}

代码示例来源:origin: groupon/FeatureAdapter

.observeOn(mainThread())
.zipWith(tickObservable, (model, tick) -> model)
.onBackpressureLatest()
.flatMap(
  model ->

代码示例来源:origin: com.pushtorefresh.storio/sqlite

.map(MapSomethingToExecuteAsBlocking.newInstance(this))  // each change triggers executeAsBlocking
      .startWith(Observable.create(OnSubscribeExecuteAsBlocking.newInstance(this))) // start stream with first query result
      .onBackpressureLatest();
} else {
  observable = Observable.create(OnSubscribeExecuteAsBlocking.newInstance(this));

代码示例来源:origin: com.pushtorefresh.storio/sqlite

.map(MapSomethingToExecuteAsBlocking.newInstance(this))  // each change triggers executeAsBlocking
      .startWith(Observable.create(OnSubscribeExecuteAsBlocking.newInstance(this))) // start stream with first query result
      .onBackpressureLatest();
} else {
  observable = Observable.create(OnSubscribeExecuteAsBlocking.newInstance(this));

代码示例来源:origin: davidmoten/rxjava-file

return o.onBackpressureDrop();
else if (backpressureStrategy == BackpressureStrategy.LATEST)
  return o.onBackpressureLatest();
else
  throw new RuntimeException("unrecognized backpressureStrategy " + backpressureStrategy);

代码示例来源:origin: com.pushtorefresh.storio/sqlite

.map(MapSomethingToExecuteAsBlocking.newInstance(this))  // each change triggers executeAsBlocking
      .startWith(Observable.create(OnSubscribeExecuteAsBlocking.newInstance(this))) // start stream with first query result
      .onBackpressureLatest();
} else {
  observable = Observable.create(OnSubscribeExecuteAsBlocking.newInstance(this));

代码示例来源:origin: com.pushtorefresh.storio/sqlite

.map(MapSomethingToExecuteAsBlocking.newInstance(this))  // each change triggers executeAsBlocking
      .startWith(Observable.create(OnSubscribeExecuteAsBlocking.newInstance(this))) // start stream with first query result
      .onBackpressureLatest();
} else {
  observable = Observable.create(OnSubscribeExecuteAsBlocking.newInstance(this));

相关文章

Observable类方法