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

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

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

Observable.empty介绍

[英]Returns an Observable that emits no items to the Observer and immediately invokes its Observer#onCompleted method.

Scheduler: empty does not operate by default on a particular Scheduler.
[中]返回一个不向观察者发送任何项的可观察对象,并立即调用其观察者#onCompleted方法。
Scheduler:默认情况下,empty不会在特定计划程序上运行。

代码示例

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

public Observable<Void> activate() {
    return Observable.empty();
  }
}

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

@Override
  public Observable<Connection<ByteBuf, ByteBuf>> newConnectionRequest() {
    return Observable.empty();
  }
};

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

@Override
public Observable<Void> discard(PooledConnection<?, ?> connection) {
  discarded.add(connection);
  return Observable.empty();
}

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

@Override
public Observable<Void> release(PooledConnection<?, ?> connection) {
  released.add(connection);
  return Observable.empty();
}

代码示例来源:origin: spring-projects/spring-framework

@PostMapping("/observable")
public Observable<Void> createWithObservable(@RequestBody Observable<Person> observable) {
  return observable.toList().doOnNext(persons::addAll).flatMap(document -> Observable.empty());
}

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

@Override
public Observable<Connection<R, W>> newConnectionRequest() {
  return channelProvider.newChannel(Observable.<Channel>empty())
             .map(new Func1<Channel, Connection<R, W>>() {
               @Override
               public Connection<R, W> call(Channel channel) {
                 return ConnectionImpl.fromChannel(channel);
               }
             });
}

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

@Test(timeout = 60000)
public void testWrite() throws Exception {
  Observable<ByteBuf> toWrite = Observable.empty();
  connRule.connection.write(toWrite);
  Mockito.verify(connRule.channelOperations).write(toWrite);
  Mockito.verifyNoMoreInteractions(connRule.channelOperations);
}

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

@Test(timeout = 60000)
public void testWriteString() throws Exception {
  Observable<String> toWrite = Observable.empty();
  connRule.connection.writeString(toWrite);
  Mockito.verify(connRule.channelOperations).writeString(toWrite);
  Mockito.verifyNoMoreInteractions(connRule.channelOperations);
}

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

@Test(timeout = 60000)
public void testWriteFileRegion() throws Exception {
  Observable<FileRegion> toWrite = Observable.empty();
  connRule.connection.writeFileRegion(toWrite);
  Mockito.verify(connRule.channelOperations).writeFileRegion(toWrite);
  Mockito.verifyNoMoreInteractions(connRule.channelOperations);
}

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

@Test(timeout = 60000)
public void testWriteStringAndFlushOnEach() throws Exception {
  Observable<String> toWrite = Observable.empty();
  connRule.connection.writeStringAndFlushOnEach(toWrite);
  Mockito.verify(connRule.channelOperations).writeStringAndFlushOnEach(toWrite);
  Mockito.verifyNoMoreInteractions(connRule.channelOperations);
}

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

@Test(timeout = 60000)
public void testWriteBytesAndFlushOnEach() throws Exception {
  Observable<byte[]> toWrite = Observable.empty();
  connRule.connection.writeBytesAndFlushOnEach(toWrite);
  Mockito.verify(connRule.channelOperations).writeBytesAndFlushOnEach(toWrite);
  Mockito.verifyNoMoreInteractions(connRule.channelOperations);
}

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

@Test(timeout = 60000)
public void testWriteFileRegionAndFlushOnEach() throws Exception {
  Observable<FileRegion> toWrite = Observable.empty();
  connRule.connection.writeFileRegionAndFlushOnEach(toWrite);
  Mockito.verify(connRule.channelOperations).writeFileRegionAndFlushOnEach(toWrite);
  Mockito.verifyNoMoreInteractions(connRule.channelOperations);
}

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

@Test(timeout = 60000)
public void testWriteAndFlushOnEach() throws Exception {
  Observable<ByteBuf> toWrite = Observable.empty();
  connRule.connection.writeAndFlushOnEach(toWrite);
  Mockito.verify(connRule.channelOperations).writeAndFlushOnEach(toWrite);
  Mockito.verifyNoMoreInteractions(connRule.channelOperations);
}

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

@Test(timeout = 60000)
public void testWriteBytes() throws Exception {
  Observable<byte[]> toWrite = Observable.empty();
  connRule.connection.writeBytes(toWrite);
  Mockito.verify(connRule.channelOperations).writeBytes(toWrite);
  Mockito.verifyNoMoreInteractions(connRule.channelOperations);
}

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

@Test(timeout = 60000)
public void testWriteFileRegionWithFlushSelector() throws Exception {
  Observable<FileRegion> toWrite = Observable.empty();
  FlushSelector<FileRegion> flushSelector = new FlushSelector<>(1);
  connRule.connection.writeFileRegion(toWrite, flushSelector);
  Mockito.verify(connRule.channelOperations).writeFileRegion(toWrite, flushSelector);
  Mockito.verifyNoMoreInteractions(connRule.channelOperations);
}

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

@Test(timeout = 60000)
public void testWriteWithFlushSelector() throws Exception {
  Observable<ByteBuf> toWrite = Observable.empty();
  FlushSelector<ByteBuf> flushSelector = new FlushSelector<>(1);
  connRule.connection.write(toWrite, flushSelector);
  Mockito.verify(connRule.channelOperations).write(toWrite, flushSelector);
  Mockito.verifyNoMoreInteractions(connRule.channelOperations);
}

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

@Test(timeout = 60000)
public void testWriteBytesWithFlushSelector() throws Exception {
  Observable<byte[]> toWrite = Observable.empty();
  FlushSelector<byte[]> flushSelector = new FlushSelector<>(1);
  connRule.connection.writeBytes(toWrite, flushSelector);
  Mockito.verify(connRule.channelOperations).writeBytes(toWrite, flushSelector);
  Mockito.verifyNoMoreInteractions(connRule.channelOperations);
}

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

@Override
  public void evaluate() throws Throwable {
    mockPipeline = Mockito.mock(DetachedChannelPipeline.class, Mockito.RETURNS_MOCKS);
    EmbeddedConnectionProvider<String, String> ecp = new EmbeddedConnectionProvider<>();
    clientState = ClientState.create(mockPipeline, ecp.asFactory(), Observable.<Host>empty())
                 .enableWireLogging(LogLevel.ERROR);
    base.evaluate();
  }
};

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

@Test
public void testCollectOverEmptyObservable() throws Exception {
  TestSubscriber<ByteBuf> t = new TestSubscriber<>();
  Observable.<ByteBuf>empty()
    .compose(CollectBytes.all())
    .subscribe(t);
  t.assertNoErrors();
  t.assertCompleted();
  t.assertValue(Unpooled.buffer());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void voidReturnType() throws Exception {
  testVoid(null, on(TestController.class).resolveReturnType(void.class));
  testVoid(Mono.empty(), on(TestController.class).resolveReturnType(Mono.class, Void.class));
  testVoid(Flux.empty(), on(TestController.class).resolveReturnType(Flux.class, Void.class));
  testVoid(Completable.complete(), on(TestController.class).resolveReturnType(Completable.class));
  testVoid(Observable.empty(), on(TestController.class).resolveReturnType(Observable.class, Void.class));
  MethodParameter type = on(TestController.class).resolveReturnType(io.reactivex.Completable.class);
  testVoid(io.reactivex.Completable.complete(), type);
  type = on(TestController.class).resolveReturnType(io.reactivex.Observable.class, Void.class);
  testVoid(io.reactivex.Observable.empty(), type);
  type = on(TestController.class).resolveReturnType(Flowable.class, Void.class);
  testVoid(Flowable.empty(), type);
}

相关文章

Observable类方法