rx java - Sequential Observable Web Service and Database Query Call -


how implement sequential web service , database query call using rxjava observable? first call database query (cache) display result (onnext or oncompleted) , after network call display (replace) current result (cache). i'm using volley listener display data.

sequential actions can implemented using concat. because 2 concatenated observables can of different types ignoreelements , cast can useful:

databasequeryobservable     .doonnext(displayresult)     .dooncomplete(something)     .ignoreelements()     .cast(object.class)     .concatwith(         networkcall             .doonnext(displaynetworkcallresult)             .dooncomplete(somethingelse)             .ignoreelements()             .cast(object.class)     ).subscribe(onnextaction, onerroraction, oncompletedaction); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -