{ // … publisher.subscribe(new Subscriber<T>() { // … @Override public void onError(Throwable t) { // Errors should be handled upstream, so propagate as a crash. throw new RuntimeException(t); } @Override public void onComplete() { } }); return liveData; }
{} final class Loading implements AddTodoState {} final class Error implements AddTodoState { final Throwable throwable; public Error(Throwable throwable) { this.throwable = throwable; } public Throwable getThrowable() { return throwable; } } final class Complete implements AddTodoState {} }