Java Code Examples for io.vertx.rx.java.RxHelper#observableHandler()

The following examples show how to use io.vertx.rx.java.RxHelper#observableHandler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NativeExamples.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
public void observableHandler(Vertx vertx) {
  ObservableHandler<Long> observable = RxHelper.observableHandler();
  observable.subscribe(id -> {
    // Fired
  });
  vertx.setTimer(1000, observable.toHandler());
}
 
Example 2
Source File: ObservableHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiNotifyBeforeSubscribe() {
  ObservableHandler<String> o = RxHelper.observableHandler(true);
  o.toHandler().handle("abc");
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  TestUtils.subscribe(o, subscriber);
  subscriber.assertEmpty();
}
 
Example 3
Source File: ObservableHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testSingleNotifyBeforeSubscribe() {
  ObservableHandler<String> o = RxHelper.observableHandler();
  o.toHandler().handle("abc");
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  TestUtils.subscribe(o, subscriber);
  subscriber.assertCompleted().assertEmpty();
}
 
Example 4
Source File: ObservableHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiNotifyAfterSubscribe() {
  ObservableHandler<String> o = RxHelper.observableHandler(true);
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  TestUtils.subscribe(o, subscriber);
  subscriber.assertEmpty();
  o.toHandler().handle("abc");
  subscriber.assertItem("abc").assertEmpty();
}
 
Example 5
Source File: ObservableHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testSingleNotifyAfterSubscribe() {
  ObservableHandler<String> o = RxHelper.observableHandler();
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  TestUtils.subscribe(o, subscriber);
  subscriber.assertEmpty();
  o.toHandler().handle("abc");
  subscriber.assertItem("abc").assertCompleted().assertEmpty();
}
 
Example 6
Source File: ObservableHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiUnsubscribeBeforeNotify() {
  ObservableHandler<String> o = RxHelper.observableHandler(true);
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  TestUtils.subscribe(o, subscriber);
  subscriber.unsubscribe();
  assertTrue(subscriber.isUnsubscribed());
  subscriber.assertEmpty();
  o.toHandler().handle("abc");
  subscriber.assertEmpty();
}
 
Example 7
Source File: ObservableHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testSingleUnsubscribeBeforeNotify() {
  ObservableHandler<String> o = RxHelper.observableHandler();
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  TestUtils.subscribe(o, subscriber);
  subscriber.unsubscribe();
  assertTrue(subscriber.isUnsubscribed());
  subscriber.assertEmpty();
  o.toHandler().handle("abc");
  subscriber.assertEmpty();
}
 
Example 8
Source File: ObservableHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiNotifyTwice() {
  ObservableHandler<String> o = RxHelper.observableHandler(true);
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  TestUtils.subscribe(o, subscriber);
  o.toHandler().handle("abc");
  o.toHandler().handle("def");
  subscriber.assertItem("abc").assertItem("def").assertEmpty();
}
 
Example 9
Source File: ObservableHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testSingleNotifyTwice() {
  ObservableHandler<String> o = RxHelper.observableHandler();
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  TestUtils.subscribe(o, subscriber);
  o.toHandler().handle("abc");
  o.toHandler().handle("def");
  subscriber.assertItem("abc").assertCompleted().assertEmpty();
}