@Override public void subscribe(final Subscriber<? super String> observer) { observer.onSubscribe(EmptySubscription.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) { } observer.onError(new NullPointerException()); return; } else { observer.onNext(s); } } System.out.println("subscription complete"); observer.onComplete(); } }); t.start(); }
@Override public void subscribe(final Subscriber<? super String> observer) { observer.onSubscribe(EmptySubscription.INSTANCE); t = new Thread( new Runnable() { @Override public void run() { observer.onNext("hello"); observer.onComplete(); } }); t.start(); }
@Override public void subscribe(final Subscriber<? super String> observer) { observer.onSubscribe(EmptySubscription.INSTANCE); t = new Thread( new Runnable() { @Override public void run() { try { Thread.sleep(100); } catch (InterruptedException e) { observer.onError(e); } observer.onNext("hello"); observer.onComplete(); } }); t.start(); }