rx.subjects.Subject.lift()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(127)

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

Subject.lift介绍

暂无

代码示例

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

@Override
  public void call(Subscriber<? super T> subscriber) {
    delegate.lift(breaker).subscribe(new SafeSubscriber<>(subscriber));
  }
}, delegate, breaker);

代码示例来源:origin: dswarm/dswarm

public Observable<GDMModel> getObservable() {
  return modelSubject.lift(new BufferOperator()).filter(m -> {
    if (!afterClosedStream.get() && !gdmModelDeque.isEmpty()) {
      gdmModelDeque.removeLast();
    }
    if (m != null) {
      outGoingCounter.incrementAndGet();
      return true;
    }
    nonOutGoingCounter.incrementAndGet();
    return false;
  }).doOnCompleted(() -> LOG
      .info("complete {} writer observable; received '{}' records + emitted '{}' (left '{}'; discarded '{}'; polled '{}') records", type,
          inComingCounter.get(),
          outGoingCounter.get(), inComingCounter.get() - outGoingCounter.get(), nonOutGoingCounter.get(),
          dequePolledCounter.get()));
}

代码示例来源:origin: com.couchbase.client/core-io

/**
 * This will eagerly dispose this {@link Subject} without waiting for the no subscription timeout period,
 * if configured.
 *
 * This must be invoked when the caller is sure that no one will subscribe to this subject. Any subscriber after
 * this call will receive an error that the subject is disposed.
 *
 * @return {@code true} if the subject was disposed by this call (if and only if there was no subscription).
 */
public boolean disposeIfNotSubscribed() {
  if (state.casState(State.STATES.UNSUBSCRIBED, State.STATES.DISPOSED)) {
    state.bufferedSubject.lift(new AutoReleaseByteBufOperator<T>()).subscribe(Subscribers.empty()); // Drain all items so that ByteBuf gets released.
    return true;
  }
  return false;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

/**
 * This will eagerly dispose this {@link Subject} without waiting for the no subscription timeout period,
 * if configured.
 *
 * This must be invoked when the caller is sure that no one will subscribe to this subject. Any subscriber after
 * this call will receive an error that the subject is disposed.
 *
 * @return {@code true} if the subject was disposed by this call (if and only if there was no subscription).
 */
public boolean disposeIfNotSubscribed() {
  if (state.casState(State.STATES.UNSUBSCRIBED, State.STATES.DISPOSED)) {
    state.bufferedSubject.lift(new AutoReleaseByteBufOperator<T>()).subscribe(Subscribers.empty()); // Drain all items so that ByteBuf gets released.
    return true;
  }
  return false;
}

代码示例来源:origin: org.hawkular.inventory/hawkular-inventory-api

private <C> SubjectAndWrapper<C> getSubjectAndWrapper(Interest<C, ?> interest, boolean initialize) {
  @SuppressWarnings("unchecked")
  SubjectAndWrapper<C> sub = (SubjectAndWrapper<C>) observables.get(interest);
  if (initialize && sub == null) {
    SubscriptionTracker tracker = new SubscriptionTracker(() -> observables.remove(interest));
    Subject<C, C> subject = PublishSubject.<C>create().toSerialized();
    //error handling:
    //OperatorIgnoreError - in case subscribers and us run in the same thread, an error in the subscriber
    //may error out the whole observable, which is definitely NOT what we want.
    Observable<C> wrapper = null;
    wrapper = subject.lift(new OperatorIgnoreError<>()).doOnSubscribe(tracker.onSubscribe())
        .doOnUnsubscribe(tracker.onUnsubscribe());
    sub = new SubjectAndWrapper<>(subject, wrapper);
    observables.put(interest, sub);
  }
  return sub;
}

相关文章