@Override public void onNext(final T v) { Subscription previousSubscription = lastScheduledNotification.getAndSet( scheduler.schedule( new Action0() { @Override public void call() { observer.onNext(v); } }, timeout, unit)); // cancel previous if not already executed if (previousSubscription != null) { previousSubscription.unsubscribe(); } }
public Subscription onSubscribe(final Observer<? super T> observer) { final Iterator<? extends T> iterator = iterable.iterator(); return scheduler.schedule( new Action1<Action0>() { @Override public void call(Action0 self) { try { if (iterator.hasNext()) { T x = iterator.next(); observer.onNext(x); self.call(); } else { observer.onCompleted(); } } catch (Exception e) { observer.onError(e); } } }); }