java - How code in RxJava Completable in which Spring controller is returning void -


i have post method return's void after saving record db. if there exception gets thrown , controlleradvice handles it.

i refactoring current code using rxjava 2 , found there completable (http://www.vogella.com/tutorials/rxjava/article.html) best suited function returns void unlike observable return deferredresult :

@requestmapping(method = get, produces = application_json_value) @responsestatus(ok) public deferredresult<user> getuser(@valid data data) throws exception {     observable<user> data = userserviceimpl.find(data);     deferredresult<user> deffered = new deferredresult<>();     data.subscribe(m -> deffered.setresult(m), e -> deffered.seterrorresult(e));     return deffered; } 

as mentioned in above example success result , error both handled.

what correct way of handling request (throw correct error when occurs), in case method returns void, , keep non-blocking, example:

@requestmapping(method = post, consumes = application_json_value, produces = application_json_value)     @responsestatus(ok)     public void setuserdata(@valid @requestbody data data) throws exception {         completable value = userserviceimpl.save(data);     } 

should return deferredresult? method should used converting completable deferredresult exception handled?

like in case of method used following

data.subscribe(m -> deffered.setresult(m), e -> deffered.seterrorresult(e)); 

what should used in case of completable?

thanks in advance help.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -