@Override public void accept(final NbpSubscriber<? super String> NbpObserver) { NbpObserver.onSubscribe(EmptyDisposable.INSTANCE); t = new Thread( new Runnable() { @Override public void run() { for (String s : valuesToReturn) { if (s == null) { System.out.println("throwing exception"); try { Thread.sleep(100); } catch (Throwable e) { } NbpObserver.onError(new NullPointerException()); return; } else { NbpObserver.onNext(s); } } System.out.println("subscription complete"); NbpObserver.onComplete(); } }); t.start(); }
@Override public void onSubscribe(Disposable s) { if (SubscriptionHelper.validateDisposable(this.s, s)) { return; } this.s = s; actual.onSubscribe(s); scheduleTimeout(0L); }