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

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

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

Observable.never介绍

[英]Returns an Observable that never sends any items or notifications to an Observer.

This Observable is useful primarily for testing purposes. Scheduler: never does not operate by default on a particular Scheduler.
[中]返回从不向观察者发送任何项目或通知的可观察对象。
这一可观测数据主要用于测试目的。调度程序:默认情况下,从不在特定调度程序上运行。

代码示例

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

public Host(SocketAddress host) {
  this(host, Observable.<Void>never());
}

代码示例来源:origin: PipelineAI/pipeline

@Override
  public Observable<R> call() {
    if (commandState.get().equals(CommandState.UNSUBSCRIBED)) {
      return Observable.never();
    }
    return applyHystrixSemantics(_cmd);
  }
};

代码示例来源:origin: Netflix/servo

@Test
public void testSendAll() throws Exception {
 List<Observable<Integer>> batches = new ArrayList<>();
 int expectedSum = 0;
 for (int i = 1; i <= 5; ++i) {
  batches.add(Observable.just(i));
  expectedSum += i;
 }
 HttpHelper httpHelper = new HttpHelper(null);
 int sent = httpHelper.sendAll(batches, expectedSum, 100L);
 assertEquals(sent, expectedSum);
 // now add an observable that should timeout
 batches.add(Observable.<Integer>never());
 int partial = httpHelper.sendAll(batches, expectedSum, 100L);
 assertEquals(partial, expectedSum);
}

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

@Override
  public Observable<Throwable> call(C client) {
    return Observable.never();
  }
};

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

@Override
  public Observable<C> call(C client) {
    return Observable.never();
  }
};

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

@Override
 public void run() {
  Observable.<Void>never().subscribe(new Action1<Void>() {
   @Override
   public void call(Void aVoid) {
    log("it's impossible!");
   }
  });
 }
}

代码示例来源:origin: eleventigers/rxeither

/**
 * Creates only left {@link Either} type emitting observable.
 */
public static <L, R> Observable<Either<L, R>> left(Observable<L> left) {
  return from(left, Observable.<R>never());
}

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

@Override
  public Observable<R> call() {
    if (commandState.get().equals(CommandState.UNSUBSCRIBED)) {
      return Observable.never();
    }
    return applyHystrixSemantics(_cmd);
  }
};

代码示例来源:origin: eleventigers/rxeither

/**
 * Creates only right {@link Either} type emitting observable.
 */
public static <L, R> Observable<Either<L, R>> right(Observable<R> right) {
  return from(Observable.<L>never(), right);
}

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

@Override
 public void run() {
  Observable.<Integer>never().timeout(1, TimeUnit.SECONDS).subscribe(new Action1<Integer>() {
   @Override
   public void call(Integer integer) {
    log(integer);
   }
  }, new Action1<Throwable>() {
   @Override
   public void call(Throwable throwable) {
    log(throwable);
   }
  });
 }
});

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

public static Observable<GroupedObservable<TypeAndNameKey, Map<String, Object>>> aggregateHttpSSE(URI... uris) {
  return aggregateHttpSSE(() -> {
    return Observable.from(uris).map(uri -> StreamAction.create(ActionType.ADD, uri)).concatWith(Observable.never()); // never() as we don't want to end
  });
}

代码示例来源:origin: peter-tackage/assert-rx

@Test
@Ignore("This test is intentionally failing - ignored so that the build passes")
public void testNeverErrors() {
  Observable<String> empty = Observable.never();
  TestSubscriber<String> ts = TestSubscriber.create();
  empty.subscribe(ts);
  assertThat(ts).hasTerminalEvent();
}

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

public CachingSelfInfoResolver(SelfInfoResolver delegate) {
  this.delegateObservable = delegate.resolve();
  this.cachingSubject = BehaviorSubject.create();
  control = Observable.<InstanceInfo>never()
      .doOnSubscribe(new Action0() {
        @Override
        public void call() {
          subscription = delegateObservable.subscribe(cachingSubject);
        }
      })
      .doOnUnsubscribe(new Action0() {
        @Override
        public void call() {
          if (subscription != null) {
            subscription.unsubscribe();
          }
        }
      })
      .share();
}

代码示例来源:origin: peter-tackage/assert-rx

@Test
public void hasReceivedAnyValues_asserts_whenSourceObservableIsNever() {
  expectAssertionErrorWithMessage("Expected received onNext events not to be empty.");
  Observable<Object> oi = Observable.never();
  TestSubscriber<Object> ts = new TestSubscriber<Object>();
  oi.subscribe(ts);
  new TestSubscriberAssert<Object>(ts, TestSubscriberAssert.class).hasReceivedAnyValues();
}

代码示例来源:origin: peter-tackage/assert-rx

@Test
public void hasReceivedAnyValue_asserts_whenSourceObservableIsNever() {
  expectAssertionErrorWithMessage("Expected received onNext events not to be empty.");
  Observable<Object> oi = Observable.never();
  TestSubscriber<Object> ts = new TestSubscriber<Object>();
  oi.subscribe(ts);
  new TestSubscriberAssert<Object>(ts, TestSubscriberAssert.class).hasReceivedAnyValue();
}

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

@Override
protected void before() throws Throwable {
  WriteServerConfig config = WriteServerConfig.writeBuilder()
      .withAppName(name)
      .withVipAddress(name)
      .withDataCenterType(DataCenterType.Basic)
      .withRegistrationPort(0)
      .withDiscoveryPort(0)
      .withReplicationPort(0)
      .withCodec(Codec.Avro)
      .withShutDownPort(0)
      .withWebAdminPort(0)
      .withReplicationRetryMillis(1000)
      .build();
  server = new EmbeddedWriteServer(config, Observable.<ChangeNotification<InetSocketAddress>>never(), false, false);
  server.start();
}

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

@Test
public void timeoutWhenServiceNeverCompletes() throws Exception {
  //given
  TestScheduler testScheduler = Schedulers.test();
  MyService mock = mockReturning(
      Observable.never(), testScheduler);
  TestSubscriber<LocalDate> ts = new TestSubscriber<>();
  //when
  mock.externalCall().subscribe(ts);
  //then
  testScheduler.advanceTimeBy(950, MILLISECONDS);
  ts.assertNoTerminalEvent();
  testScheduler.advanceTimeBy(100, MILLISECONDS);
  ts.assertCompleted();
  ts.assertNoValues();
}

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

@Override
protected void before() throws Throwable {
  WriteServerConfig config = WriteServerConfig.writeBuilder()
      .withAppName(name)
      .withVipAddress(name)
      .withReadClusterVipAddress(readClusterName)
      .withDataCenterType(DataCenterType.Basic)
      .withHttpPort(0)
      .withRegistrationPort(0)
      .withDiscoveryPort(0)
      .withReplicationPort(0)
      .withCodec(codec)
      .withShutDownPort(0)
      .withWebAdminPort(0)
      .withReplicationRetryMillis(1000)
      .build();
  Observable<ChangeNotification<Server>> noPeers = Observable.never();
  server = new EmbeddedWriteServer(config, noPeers, noPeers, false, false);
  server.start();
}

相关文章

Observable类方法