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
Post a Comment