@Override public void run() { Observable.<Object>// just(1, "2", // new Exception("abc")). ofType(Integer.class).subscribe(new Action1<Integer>() { @Override public void call(Integer integer) { log(integer); } }); } }
public Labels(Observable<ReadCommand> readObservable, PublishSubject<WriteCommand> writeObservable) { readObservable.ofType(BroadcastLabelsCommand.class).subscribe(this); writeObservable.onNext(new LabelsRequestCommand()); }
private void installAcknowledgementHandler() { connection.getInput() .ofType(Acknowledgement.class) .subscribe(new Action1<Acknowledgement>() { @Override public void call(Acknowledgement acknowledgement) { PendingAck pending = pendingAckQueue.poll(); metrics.decrementPendingAckCounter(); if (pending == null) { shutdown(new IllegalStateException("{connection=" + name + "}: unexpected acknowledgment")); } else { pending.ackSubject.onCompleted(); } } }); schedulerWorker.schedule(ackTimeoutTask, 1, TimeUnit.SECONDS); }
@Override public Observable<E> call(Observable<F> effects) { return effects .ofType(effectClass) .compose(effectHandler) .doOnError(onErrorFunction.call(effectHandler)); } });
readObservable.ofType(BaudRateSetCommand.class).subscribe(new Action1<BaudRateSetCommand>() {
public static void main(String[] args) { // Configure for remote RaspberryPI with serial dongle and ser2net setup on port 2000 TCP. final IT100 it100 = new IT100(new ConfigurationBuilder().withRemoteSocket("raspberrypi", 2000).build()); try { // Start communicating with IT-100. it100.connect(); final Observable<ReadCommand> readObservable = it100.getReadObservable(); // Labels gives us friendly names to our zones. final Labels labels = new Labels(readObservable, it100.getWriteObservable()); // Subscribe to Zone opening events readObservable.ofType(ZoneOpenCommand.class).subscribe(new Action1<ZoneOpenCommand>() { @Override public void call(ZoneOpenCommand t1) { // Print time and name of zone that opened. System.out.println(System.currentTimeMillis() + " " + labels.getZoneLabel(t1.getZone()) + " opened."); } }); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }