Examples of Action0


Examples of hu.akarnokd.reactive4java.base.Action0

  public static <T> Observable<T> create(
      @Nonnull final Func1<Observer<? super T>, ? extends Action0> subscribe) {
    return new Observable<T>() {
      @Override
      public Closeable register(Observer<? super T> observer) {
        final Action0 a = subscribe.invoke(observer);
        return new Closeable() {
          @Override
          public void close() {
            a.invoke();
          }
        };
      }
    };
  }
View Full Code Here

Examples of lombok.Actions.Action0

   *           methods have the specified name
   */
  @Validate
  public static Action0 invokeMethodWithNoArgsOn(@NotNull final Object obj, @NotNull final String methodName)
  {
    return new Action0() {

      private final Method method;

      // initialiser block
      {
View Full Code Here

Examples of propel.core.functional.Actions.Action0

   *           methods have the specified name
   */
  @Validate
  public static Action0 invokeMethodWithNoArgsOn(@NotNull final Object obj, @NotNull final String methodName)
  {
    return new Action0() {

      private final Method method;

      // initialiser block
      {
View Full Code Here

Examples of propel.core.functional.Actions.Action0

   * @throws Throwable When the action is called
   */
  @Validate
  public static Action0 throwException(@NotNull final Throwable _e)
  {
    return new Action0() {
      @Override
      @SneakyThrows
      public void apply()
      {
        Throwable actual;
View Full Code Here

Examples of rx.functions.Action0

                     }, new Action1<Throwable>() {
                         @Override
                         public void call(Throwable e) {
                             System.out.println("failed to subscribe 'onhello': " + e);
                         }
                     }, new Action0() {
                         @Override
                         public void call() {
                             System.out.println("'onhello' subscription ended");
                         }
                     });
                   
                    // REGISTER a procedure for remote calling
                    addProcSubscription = client.registerProcedure("com.example.add2")
                                                .observeOn(rxScheduler)
                                                .subscribe(new Action1<Request>() {
                        @Override
                        public void call(Request request) {
                            if (request.arguments() == null || request.arguments().size() != 2
                             || !request.arguments().get(0).canConvertToLong()
                             || !request.arguments().get(1).canConvertToLong())
                            {
                                try {
                                    request.replyError(new ApplicationError(ApplicationError.INVALID_PARAMETER));
                                } catch (ApplicationError e) { }
                            }
                            else {
                                long a = request.arguments().get(0).asLong();
                                long b = request.arguments().get(1).asLong();
                                request.reply(a + b);
                            }
                        }
                    }, new Action1<Throwable>() {
                        @Override
                        public void call(Throwable e) {
                            System.out.println("failed to register procedure: " + e);
                        }
                    }, new Action0() {
                        @Override
                        public void call() {
                            System.out.println("procedure subscription ended");
                        }
                    });
                   
                    // PUBLISH and CALL every second .. forever
                    counter = 0;
                    counterPublication = rxScheduler.createWorker().schedulePeriodically(new Action0() {
                        @Override
                        public void call() {
                            // PUBLISH an event
                            final int published = counter;
                            client.publish("com.example.oncounter", published)
                                  .observeOn(rxScheduler)
                                  .subscribe(new Action1<Long>() {
                                    @Override
                                    public void call(Long t1) {
                                        System.out.println("published to 'oncounter' with counter " + published);
                                    }
                                }, new Action1<Throwable>() {
                                    @Override
                                    public void call(Throwable e) {
                                        System.out.println("Error during publishing to 'oncounter': " + e);
                                    }
                                });
                           
                            // CALL a remote procedure
                            client.call("com.example.mul2", Long.class, counter, 3)
                                  .observeOn(rxScheduler)
                                  .subscribe(new Action1<Long>() {
                                    @Override
                                    public void call(Long result) {
                                        System.out.println("mul2() called with result: " + result);
                                    }
                                }, new Action1<Throwable>() {
                                    @Override
                                    public void call(Throwable e) {
                                        boolean isProcMissingError = false;
                                        if (e instanceof ApplicationError) {
                                            if (((ApplicationError) e).uri().equals("wamp.error.no_such_procedure"))
                                                isProcMissingError = true;
                                        }
                                        if (!isProcMissingError) {
                                            System.out.println("call of mul2() failed: " + e);
                                        }
                                    }
                                });
                           
                            counter++;
                        }
                    }, TIMER_INTERVAL, TIMER_INTERVAL, TimeUnit.MILLISECONDS);
                }
                else if (t1 == WampClient.Status.Disconnected) {
                    closeSubscriptions();
                }
            }
        }, new Action1<Throwable>() {
            @Override
            public void call(Throwable t) {
                System.out.println("Session ended with error " + t);
            }
        }, new Action0() {
            @Override
            public void call() {
                System.out.println("Session ended normally");
            }
        });
View Full Code Here

Examples of rx.functions.Action0

        }
    }

    private void scheduleForRetry(final CouchbaseRequest request) {
        final AtomicReference<Subscription> subscription = new AtomicReference<Subscription>();
        subscription.set(worker.schedule(new Action0() {
            @Override
            public void call() {
                cluster.send(request);
                subscription.get().unsubscribe();
            }
View Full Code Here

Examples of rx.functions.Action0

        LOGGER.debug("Config for bucket \"" + config.name() + "\" marked as tainted, starting polling.");
        Observable.create(new Observable.OnSubscribe<Object>() {
            @Override
            public void call(final Subscriber<? super Object> subscriber) {
                Subscription subscription = environment.scheduler().createWorker().schedulePeriodically(new Action0() {
                    @Override
                    public void call() {
                        final InetAddress hostname = config.nodes().get(0).hostname();
                        cluster()
                            .<GetBucketConfigResponse>send(new GetBucketConfigRequest(config.name(), hostname))
View Full Code Here

Examples of rx.functions.Action0

        private boolean isWaitingForResponse;

        private long responseReceiveStartTimeMillis; // Reset every time we receive a header.

        private ResponseState() {
            contentSubject = UnicastContentSubject.createWithoutNoSubscriptionTimeout(new Action0() {
                @Override
                public void call() {
                    if (null != connection) {
                        connection.close();
                    }
View Full Code Here

Examples of rx.functions.Action0

                                                                              httpClientConfig.getResponseSubscriptionTimeoutMs()));

        if (followRedirect) {
            toReturn = toReturn.lift(new RedirectOperator<I, O>(request, this, httpClientConfig));
        }
        return toReturn.take(1).finallyDo(new Action0() {
            @Override
            public void call() {
                eventsSubject.onEvent(HttpClientMetricsEvent.REQUEST_PROCESSING_COMPLETE,
                                      Clock.onEndMillis(startTimeMillis));
            }
View Full Code Here

Examples of rx.functions.Action0

                                                 eventsSubject.onEvent(HttpClientMetricsEvent.RESPONSE_FAILED,
                                                                       Clock.onEndMillis(startTimeMillis), throwable);
                                             }
                                         })
                                         .subscribe(child)); //subscribe the child for response.
                        request.doOnWriteComplete(new Action0() {
                            @Override
                            public void call() {
                                connection.flush().subscribe(new Observer<Void>() {
                                    @Override
                                    public void onCompleted() {
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.