Examples of RxEventBus


Examples of io.vertx.rxcore.java.eventbus.RxEventBus

  }

  @Test
  public void testFlow() {

    final RxEventBus rx=new RxEventBus(vertx.eventBus());

    vertx.eventBus().registerHandler("countdown", new Handler<Message<Integer>>() {

      public void sendBatch(final Message<Integer> msg, int from, int length) {
        JsonArray res = new JsonArray();
        for (int i = from; i < from+length; i++) {
          res.add(i);
        }
        // As long as above 0 wait for another request
        if (from > 0) {
          msg.reply(res, this);
        } else {
          msg.reply(res);
        }
      }

      public void handle(Message<Integer> msg) {
        sendBatch(msg, msg.body(), 10);
      }
    });

    Regulator regulator=new Regulator<>();

    Observable<RxStream<Integer,JsonArray>> res=rx.<Integer,JsonArray>observeStream("countdown", 4000)
      // Add the regulator gate here
      .lift(regulator)
      // Process the stream
      .map(new Func1<RxStream<Integer, JsonArray>, JsonArray>() {
        public JsonArray call(RxStream<Integer, JsonArray> s) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.