Is Observable
I have a CRUD repository that I am rewriting with RxJava so that the methods return some form of Observable. The only method I am not sure about is this one:
Observable<Void> delete(T entity)
I am wondering if this type of method definition is considered best practice. If not, please let me know if there is a better way to define a method that is asynchronous but does not return anything. Here is my current code for unit testing that method:Observable<Void> delete(T entity)
repository
.delete(entity)
.timeout(1, TimeUnit.SECONDS)
.toBlocking()
.singleOrDefault(null);
All that I need to test for is that the onCompleted method is invoked on the subscriber. Using singleOrDefault seems like an easier way to accomplish this. Please let me know if there is a more appropriate way to use/test this method.
Read full article from Is Observable
No comments:
Post a Comment